1
当我尝试将用户移动到Active Directory中的其他组织单位时,出现System.UnauthorizedAccessException {"Access is denied."}
错误。将用户移动到Active Directory中的OU(访问被拒绝错误)
以下是我正在使用的代码。错误发生在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的单独许可?感谢您的回复 –