# vbscript probs with Active Directory



## MDub2112 (Apr 13, 2005)

Hiya All,
I'm no developer by any means...However, I've slapped my brains silly with this one.

I've run this script before with no problem; yet, now, it doesn't seem to want to work at all.

Basically, I'm in the midst of an Active Directory Migration.
I've used the Active Directory Migration Tool to migrate all of the users, no problems there.
Anyway, I'm trying to rename a batch of users, so that their container name (cn) matches their display name (displayName). Every time I run the script (shown below), I keep getting "(null): The server is unwilling to process the request".

This is a Windows 2003 Active Directory

Any ideas on why?


```
'////  Declare Domain & OU variables
Option Explicit
'On Error Resume Next
Dim objRoot, Domain, objOU, OU 
Dim objUser, OldCN, NewCN

'///////////////////////////////////////////////////////////
'////  Set Domain Variable 
Set objRoot = GetObject("LDAP://RootDSE")
Domain = objRoot.Get("DefaultNamingContext")

'///////////////////////////////////////////////////////////
'////  Prompt for name of the OU to work with 
objOU = InputBox ("Please enter the User container "_
        & "that you wish to work from")
OU = "OU=" & objOU & ",OU=UserAccounts," & Domain

'///////////////////////////////////////////////////////////
'////  Verify full Distinguished Name after OU prompt 
MsgBox ("All user objects in the " & OU &_
       " OU will be modified")

'///////////////////////////////////////////////////////////
'////  Bind to the specified OU
Set objOU = GetObject("LDAP://" & OU)

For each objUser in objOU
   If objUser.class="user" then
	   OldCN = "CN=" & objUser.cn  & "," &  OU
	   NewCN = "CN=" & objUser.displayName
      objUser.MoveHere "LDAP://"&OldCN, NewCN
      objUser.SetInfo
'/////// Added Echo for Verification and Testing'         
         WScript.Echo "The OldCN is: " & OldCN & vbCrLf &_
         "The NewCN will be: " & NewCN & vbCrLf
   End If
Next
```


----------

