更新时间:2022-05-19 17:02:58
这个问题花了我很多时间才解决.首先,错误信息看起来像一个笑话.其次,没有别的了,只有那个消息.
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=optional,DC=your-domain,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("Remove", new object[] { userDn });
工作.然而,这个邪恶的广告只有在你使用小写remove"时才有效,所以 entry.Invoke("remove", new object[] { 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.