The server does not want to process the request - Active Directory - Add user through C #

I used the example in this page to add the user to the Active Directory group, but I get an exception with the message "Server does not want to process the request" at execution

dirEntry.Properties["member"].Add(userDn);

+9
active-directory active-directory-group
source share
4 answers

This question took me a lot of time to resolve. First of all, the error message looks like a joke. Secondly, there is nothing more, just this message.

In any case, I managed to fix this:

  • Make sure userDn contains the entire path (for example, "LDAP://server-address/CN=" + userDn + ",OU=optional,DC=your-domain,DC=com" . "LDAP://server-address/CN=" + userDn + ",OU=optional,DC=your-domain,DC=com" This is really very important if you don’t provide the full path, it will throw an exception to HRESULT: 0x80005000 .

  • Replacing dirEntry.Properties["member"].Add(userDn); on entry.Invoke("Add", new object[] { userDn });

Then I wanted to remove the user, and I expected entry.Invoke("Remove", new object[] { userDn }); will work. However, this diabolical AD will only work if you use the lowercase "delete" , so entry.Invoke("Remove", new object[] { userDn }); worked for me.

+1
source share

I had a similar problem when I tried to add a member to the group. In particular, an attempt to add a group to the group and get the same useful error "The server does not want to process the request." The answer provided by OP does not work for me.

For me, the reason I couldn't add a group to my group was because the group I was trying to add members to was a "global" area, while it was supposed to be a "universal" group. Hope this helps someone.

+4
source share

Just look, because the beginning of .properties("distinguished Name") may be different from .properties("cn") . If the user is created with , or ; in .properties("cn") beginning of .properties("distinguished Name") will be the username with \, or \; ,

This may result in an error if you try to add the user that you found using .properties("cn") to the group.

0
source share

After many days of searching, I find the problem. when you add a user to a group, you must set the "distinguished name" and not the LDAP path.

You should write like this:

 ent.Properties["member"].Add("CN=YourUserName,OU=optional,DC=yourdomain,DC=com"); 

This is the wrong code:

 ent.Properties["member"].Add("LDAP://CN=YourUserName,OU=optional,DC=yourdomain,DC=com"); 

Also, when you remove the mast to save this rule

 ent.Properties["member"].Remove("CN=YourUserName,OU=optional,DC=yourdomain,DC=com"); 

PS ent is a DirectoryEntry group object

-2
source share

All Articles