我正在尝试使用C#来操作AD LDS。
我已经可以通过管理员帐户连接到AD了。像这样:
DirectoryEntry entry = new DirectoryEntry("LDAP://serverip/CN=xxx,DC=yyy,DC=com", username, password,AuthenticationTypes.ServerBind);
'用户名'和'密码'是管理员和密码。
然后我在我的服务器上创建一个用户。我设置了UserPrincipalName as 'william'
及其密码。我还设置了msDS-UserAccountDisabled = false
我尝试使用C#
记录此用户Directory entry = new Directory("LDAP:\\serverid\CN=xxx,DC=YYY,DC=com",username,pwd,AuthenticationTypes.ServerBind);
entry.RefreshCache();
当我没有将'william'放入'Administrator'组时,代码entry.RefreshCache();
总是抛出异常;但当我把'威廉'放入'管理者'时,这段代码突然有效。
我认为这是关于许可的问题,但我无法弄明白。
任何人都可以告诉我为什么这样可行。我怎样才能改变这种方法。你知道我不希望make user成为管理员。