且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

服务器不愿意处理请求-Active Directory-通过C#添加用户

更新时间:2022-01-14 17:26:12

这个问题花了我很多时间解决。首先,错误消息看起来像个玩笑。其次,仅此消息便无所事事。

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:


  1. 确保 userDn 包含整个路径(例如 LDAP:// server-address / CN = + userDn +,OU =可选,DC =您的域,DC = com 。如果您没有提供完整的信息,这实际上非常重要路径将引发HRESULT中的异常:0x80005000

  1. 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.