Home All Groups Group Topic Archive Search About


Author
2 May 2007 2:16 PM
Mike
Hello, I'm running the script below to rename computers in a domain from a
comma separated list. I'm getting an error (8007200E) "The directory server
is busy" when it gets to objComputer.Put "sAMAccountName",newname&"$"

I've tried it at different times of the day when the server is not busy but
still getting the same error. I didn't write this script so I don't fully
understand what it is attempting but I'm hoping someone in here can shed
some light on it. All the variables (domain and credentials) are correct
with sufficient permissions.

Regards,
Mike.







Set objNetwork = CreateObject("WScript.Network")
strComputer = uCase(objNetwork.ComputerName)

strBase="<LDAP://dc=domain,dc=local>;"
strFilter="(cn="+strComputer+");"
strAttrs="cn,distinguishedName;"
strScope="Subtree"
strU = "ntconnect"
strP = "ntconnect"

Set objConn=CreateObject("ADODB.Connection")
objConn.Provider="ADsDSOObject"
objConn.Open "Active Directory Provider"
Set objRS=objConn.Execute(strBase&strFilter&strAttrs&strScope)
objRS.MoveFirst
adloc=objRS.Fields("distinguishedName")
poscomma=InStr(adloc,",")+1
adloc=Mid(adloc,poscomma,1000)


Set file_sys_obj = CreateObject("Scripting.FileSystemObject")
Set file_read = file_sys_obj.GetFile("\\server\netlogon\names.txt")
Set txtstream=file_read.openastextstream(1)
Do until txtstream.AtEndOfStream
  regel=txtstream.readline
  testname=ucase(mid(regel,1,InStr(regel,",")-1))
  newname=UCase(Mid(regel,InStr(regel,",")+1,1000))
  If strcomputer = testname Then
   oldcn="cn="+strcomputer
   newcn="cn="+newname
   Set objCont=GetObject ("LDAP://"&adloc)
   objCont.MoveHere "LDAP://" & oldcn & "," & adloc, newcn
   strObject=newcn & "," & adloc
   Set objComputer=GetObject("LDAP://"&strObject)
   objComputer.Put "DNSHostName",newname&".domain.local"
   objComputer.SetInfo
   objComputer.Put "sAMAccountName",newname&"$"
   objComputer.SetInfo
   objComputer.Put "displayName",newname&"$"
   objComputer.SetInfo


   Set oShell=CreateObject("WScript.Shell")
   oShell.RegWrite
"HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName\ComputerName",newname,"REG_SZ"
   oShell.RegWrite
"HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName",newname,"REG_SZ"
   oShell.RegWrite
"HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Hostname",newname,"REG_SZ"
   oShell.RegWrite
"HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\NV
Hostname",newname,"REG_SZ"
  End If
loop
txtstream.close

Author
2 May 2007 5:49 PM
Richard Mueller [MVP]
Not sure what the problem might be, but sAMAccountName's are limited to 20
characters (including the trailing "$") and should not have any of the
following characters:

" / \ [ ] : ; |  , + * ? < >

Other than that, the value must be unique in the domain. Also, you only need
to invoke SetInfo once per object, after all values have been assigned.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--

Show quote
"Mike" <re***@togroup.com> wrote in message
news:OaWUxRMjHHA.4768@TK2MSFTNGP05.phx.gbl...
> Hello, I'm running the script below to rename computers in a domain from a
> comma separated list. I'm getting an error (8007200E) "The directory
> server is busy" when it gets to objComputer.Put
> "sAMAccountName",newname&"$"
>
> I've tried it at different times of the day when the server is not busy
> but still getting the same error. I didn't write this script so I don't
> fully understand what it is attempting but I'm hoping someone in here can
> shed some light on it. All the variables (domain and credentials) are
> correct with sufficient permissions.
>
> Regards,
> Mike.
>
>
>
>
>
>
>
> Set objNetwork = CreateObject("WScript.Network")
> strComputer = uCase(objNetwork.ComputerName)
>
> strBase="<LDAP://dc=domain,dc=local>;"
> strFilter="(cn="+strComputer+");"
> strAttrs="cn,distinguishedName;"
> strScope="Subtree"
> strU = "ntconnect"
> strP = "ntconnect"
>
> Set objConn=CreateObject("ADODB.Connection")
> objConn.Provider="ADsDSOObject"
> objConn.Open "Active Directory Provider"
> Set objRS=objConn.Execute(strBase&strFilter&strAttrs&strScope)
> objRS.MoveFirst
> adloc=objRS.Fields("distinguishedName")
> poscomma=InStr(adloc,",")+1
> adloc=Mid(adloc,poscomma,1000)
>
>
> Set file_sys_obj = CreateObject("Scripting.FileSystemObject")
> Set file_read = file_sys_obj.GetFile("\\server\netlogon\names.txt")
> Set txtstream=file_read.openastextstream(1)
> Do until txtstream.AtEndOfStream
>  regel=txtstream.readline
>  testname=ucase(mid(regel,1,InStr(regel,",")-1))
>  newname=UCase(Mid(regel,InStr(regel,",")+1,1000))
>  If strcomputer = testname Then
>   oldcn="cn="+strcomputer
>   newcn="cn="+newname
>   Set objCont=GetObject ("LDAP://"&adloc)
>   objCont.MoveHere "LDAP://" & oldcn & "," & adloc, newcn
>   strObject=newcn & "," & adloc
>   Set objComputer=GetObject("LDAP://"&strObject)
>   objComputer.Put "DNSHostName",newname&".domain.local"
>   objComputer.SetInfo
>   objComputer.Put "sAMAccountName",newname&"$"
>   objComputer.SetInfo
>   objComputer.Put "displayName",newname&"$"
>   objComputer.SetInfo
>
>
>   Set oShell=CreateObject("WScript.Shell")
>   oShell.RegWrite
> "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName\ComputerName",newname,"REG_SZ"
>   oShell.RegWrite
> "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName",newname,"REG_SZ"
>   oShell.RegWrite
> "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Hostname",newname,"REG_SZ"
>   oShell.RegWrite
> "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\NV
> Hostname",newname,"REG_SZ"
>  End If
> loop
> txtstream.close
Author
3 May 2007 2:51 AM
Mike
Hi Richard,

Thanks for your reply. Of course I am using a unique names, maximum of 15
characters and do not include any banned characters. Thanks for your advice
on the Set.Info, I switched the script around as per below; now it fails on
the Set.Info line, same error code 8007200E, error the directory service is
busy. source: (null).

objComputer.Put "DNSHostName",newname&".domain.local"
objComputer.Put "sAMAccountName",newname&"$"
objComputer.Put "displayName",newname&"$"
objComputer.SetInfo

Regards,
Mike.



Show quote
"Richard Mueller [MVP]" <rlmueller-nospam@ameritech.nospam.net> wrote in
message news:OCC$XJOjHHA.5012@TK2MSFTNGP04.phx.gbl...
> Not sure what the problem might be, but sAMAccountName's are limited to 20
> characters (including the trailing "$") and should not have any of the
> following characters:
>
> " / \ [ ] : ; |  , + * ? < >
>
> Other than that, the value must be unique in the domain. Also, you only
> need to invoke SetInfo once per object, after all values have been
> assigned.
>
> --
> Richard Mueller
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
> --
>
> "Mike" <re***@togroup.com> wrote in message
> news:OaWUxRMjHHA.4768@TK2MSFTNGP05.phx.gbl...
>> Hello, I'm running the script below to rename computers in a domain from
>> a comma separated list. I'm getting an error (8007200E) "The directory
>> server is busy" when it gets to objComputer.Put
>> "sAMAccountName",newname&"$"
>>
>> I've tried it at different times of the day when the server is not busy
>> but still getting the same error. I didn't write this script so I don't
>> fully understand what it is attempting but I'm hoping someone in here can
>> shed some light on it. All the variables (domain and credentials) are
>> correct with sufficient permissions.
>>
>> Regards,
>> Mike.
>>
>>
>>
>>
>>
>>
>>
>> Set objNetwork = CreateObject("WScript.Network")
>> strComputer = uCase(objNetwork.ComputerName)
>>
>> strBase="<LDAP://dc=domain,dc=local>;"
>> strFilter="(cn="+strComputer+");"
>> strAttrs="cn,distinguishedName;"
>> strScope="Subtree"
>> strU = "ntconnect"
>> strP = "ntconnect"
>>
>> Set objConn=CreateObject("ADODB.Connection")
>> objConn.Provider="ADsDSOObject"
>> objConn.Open "Active Directory Provider"
>> Set objRS=objConn.Execute(strBase&strFilter&strAttrs&strScope)
>> objRS.MoveFirst
>> adloc=objRS.Fields("distinguishedName")
>> poscomma=InStr(adloc,",")+1
>> adloc=Mid(adloc,poscomma,1000)
>>
>>
>> Set file_sys_obj = CreateObject("Scripting.FileSystemObject")
>> Set file_read = file_sys_obj.GetFile("\\server\netlogon\names.txt")
>> Set txtstream=file_read.openastextstream(1)
>> Do until txtstream.AtEndOfStream
>>  regel=txtstream.readline
>>  testname=ucase(mid(regel,1,InStr(regel,",")-1))
>>  newname=UCase(Mid(regel,InStr(regel,",")+1,1000))
>>  If strcomputer = testname Then
>>   oldcn="cn="+strcomputer
>>   newcn="cn="+newname
>>   Set objCont=GetObject ("LDAP://"&adloc)
>>   objCont.MoveHere "LDAP://" & oldcn & "," & adloc, newcn
>>   strObject=newcn & "," & adloc
>>   Set objComputer=GetObject("LDAP://"&strObject)
>>   objComputer.Put "DNSHostName",newname&".domain.local"
>>   objComputer.SetInfo
>>   objComputer.Put "sAMAccountName",newname&"$"
>>   objComputer.SetInfo
>>   objComputer.Put "displayName",newname&"$"
>>   objComputer.SetInfo
>>
>>
>>   Set oShell=CreateObject("WScript.Shell")
>>   oShell.RegWrite
>> "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName\ComputerName",newname,"REG_SZ"
>>   oShell.RegWrite
>> "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName",newname,"REG_SZ"
>>   oShell.RegWrite
>> "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Hostname",newname,"REG_SZ"
>>   oShell.RegWrite
>> "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\NV
>> Hostname",newname,"REG_SZ"
>>  End If
>> loop
>> txtstream.close
>
>

AddThis Social Bookmark Button