问题描述
我在将用户添加到Active Directory组中,但是执行时出现消息服务器不愿意处理请求的异常
I used the example in this page to add a user to an Active Directory group, but I get an exception with the message "Server is unwilling to process the request" when executing
dirEntry.Properties [ member]。Add(userDn);
推荐答案
这个问题花了我很多时间解决。首先,错误消息看起来像个玩笑。其次,仅此消息便无所事事。
This question took me a lot of time to solve. First of all, the error message looks like a joke. Second, there is nothing more, just that message.
无论如何,我设法通过以下方式解决了该问题:
Anyway, I managed to fix it by:
-
确保
userDn
包含整个路径(例如LDAP:// server-address / CN = + userDn +,OU =可选,DC =您的域,DC = com
。如果您没有提供完整的信息,这实际上非常重要路径将引发HRESULT中的异常:0x80005000 。
Making sure that
userDn
contains the whole path (e.g.,"LDAP://server-address/CN=" + userDn + ",OU=optional,DC=your-domain,DC=com"
. This is actually very important, if you don't supply the full path it will throw an Exception from HRESULT: 0x80005000.
替换 dirEntry.Properties [ member ] .Add(userDn);
通过 entry.Invoke( Add,new object [] {userDn});
然后我想删除一个用户,并且希望起作用。但是,仅当您使用小写的删除 时,此卑鄙的广告才有效,因此 entry.Invoke( 删除,新对象[] {userDn});
为我工作。
Then I wanted to remove a user and I expected entry.Invoke("Remove", new object[] { userDn });
to work. However, this devilish AD will only work if you use lower case "remove", so entry.Invoke("remove", new object[] { userDn });
worked for me.
这篇关于服务器不愿意处理请求-Active Directory-通过C#添加用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!