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的單獨許可?感謝您的回覆 –