Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more: , +
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
Posted
Comments
Asmita Bhurke 18-Apr-16 2:56am    
Is the other machine is also windows server 2012 with IIS 8.0?
Prashant. B. Chavan 18-Apr-16 17:07pm    
Can you provide exact error message?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900