Hello,I am not very good in English but I will try to explain my problem in simple as I can,I try to build web method in web service which create user in active directory,when I invoke this method locally from browser in server it work fine but when I invoke this method from browser in another machine it gets an error,I work on windows server 2012 and my method in c# and I use IIS 8
I think problem in permission but I can't detect it
can any one help me
note:there is no problem when I invoke method which read from Active directory only when i try to modify or write
method:
public void localCreation(String firstName,String initials,String lastName, String password, String type,int x)
{
DirectoryEntry localMachine = new DirectoryEntry("WinNT://" + Environment.MachineName);
DirectoryEntry newUser = null;
String username = firstName + " " + lastName;
if (type.Equals("user"))
{
newUser = localMachine.Children.Add(username, "user");
newUser.Invoke("SetPassword", new object[] { password });
newUser.CommitChanges();
newUser.Close();
//get distinguished name
String dn = getDnName(username);
newUser = new DirectoryEntry(dn);
newUser.Properties["userPrincipalName"].Value =firstName + "@" + LDAPDomain;
newUser.Properties["sAMAccountName"].Value = firstName;
newUser.Properties["givenName"].Value = firstName;
newUser.Properties["sn"].Value = lastName;
newUser.Properties["initials"].Value = initials;
if(x==1)
{
newUser.Properties["pwdLastSet"].Value=0;
}
else if(x==2)
{
setcannotchangepass(newUser);
}
else if(x==3)
{
newUser.Properties["userAccountControl"].Value = 65536;
}
else if(x==4)
{ //normal accont
newUser.Properties["userAccountControl"].Value = 512;
//disable accont
newUser.Properties["userAccountControl"].Value = 2;
}
newUser.CommitChanges();
localMachine.Close();
newUser.Close();
}
}
What I have tried:
I try to change in IIS Authentication and I change Anonymous user identity to Administrator and I search on the Internet to solve this problem but i can't solve it