【发布时间】:2013-11-04 12:56:25
【问题描述】:
当我尝试将用户移动到 Active Directory 中的不同组织单位时,我收到 System.UnauthorizedAccessException {"Access is denied."} 错误。
下面是我正在使用的代码。调用MoveTo 时会引发错误。如果我注释掉对MoveTo 的调用,则在调用CommitChanges 时用户的电话号码更新成功,这表明这可能不是权限错误。
是否有人能够解释为什么我不能将用户移动到新的 OU?
Try
Using Entry As DirectoryEntry = GetDirectoryEntry(DomainLogin) 'Retrieves the directory entry for the user.
Entry.Properties("telephoneNumber").Value = "9999999" 'This successfully changes the user's phone number
Dim strUserPass As String() = nBase.oAppControl.GetADUsernameAndPassword()
'Create DirectoryEntry for the target OU
Dim newLocation As DirectoryEntry = New DirectoryEntry("LDAP://testgrp.local/OU=Accounts,DC=local", strUserPass(0), strUserPass(1))
Entry.MoveTo(newLocation) 'Throws exception
Entry.CommitChanges()
Return True
End Using
Catch ex As Exception
Return False
End Try
【问题讨论】:
-
您确定使用
strUserPass传递的凭据具有移动用户的权限吗? -
你能通过 GUI 移动用户吗?像 Active Directory 用户和计算机控制台?
-
我明天会仔细检查权限并通过 Windows 尝试。
strUserPass的凭据允许更改电话号码 - 是否有将用户移动到 OU 的单独权限?感谢您的回复 -
我在尝试通过 GUI 移动时收到
Access is Denied,所以它一定是权限问题。有谁知道我需要哪些特定权限才能跨 OU 移动用户?
标签: .net vb.net active-directory