2013-11-04 76 views
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 
+1

您確定通過'strUserPass'傳入的憑據是否具有移動用戶的權限? –

+1

你可以通過GUI移動用戶嗎?像Active Directory用戶和計算機控制檯一樣? –

+0

我會仔細檢查明天的權限,並通過Windows嘗試。 'strUserPass'憑證允許更改電話號碼 - 是否有將用戶移至OU的單獨許可?感謝您的回覆 –

回答

0

雖然這是你的問題爲時已晚,但對於那些誰具有相同的問題,因爲我查了一下,在OU移動用戶的最小權限是Account Operator。 肯定Enterprise AdminDomain Admin有更多的特權。

相關問題