2013-11-04 56 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有更多的特权。

相关问题