> Here you go:
>
> Const ADS_SCOPE_SUBTREE = 2
>
> Set oConnection = CreateObject("ADODB.Connection")
> Set oCommand = CreateObject("ADODB.Command")
> oConnection.Provider = "ADsDSOObject"
> oConnection.Open "Active Directory Provider"
> Set oCommand.ActiveConnection = oConnection
>
> oCommand.Properties("Page Size") = 1000
> oCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
>
> sName = "UserX"
>
> bFound = False
> iCount = 1
>
> While bFound = False
> oCommand.CommandText = _
> "SELECT * FROM 'LDAP://dc=yourDomainName,dc=com' WHERE
> objectCategory='user' " & _
> "AND samAccountName='" & sName & iCount & "'"
> Set oRecordSet = oCommand.Execute
>
> If oRecordset.RecordCount > 0 Then
> iCount = iCount + 1
> Else
> bFound = True
> sOrgName = sName & iCount
> End If
> Wend
>
> WScript.Echo sName
>
> hth
> Marcin
>
> "thehump" <thehump.3ipvnc[ at ]DoNotSpam.com> wrote in message
> news:thehump.3ipvnc[ at ]DoNotSpam.com...
>>
>> Does anyone have a script that will check AD for a samaccountname to
>> make sure it is unique. If it isn't, the script should append a 01, 02,
>> 03, etc.
>> Thanks in advance!!
>>
>>
>> --
>> thehump
>> ------------------------------------------------------------------------
>> thehump's Profile:
http://forums.techarena.in/members/thehump.htm>> View this thread:
http://forums.techarena.in/server-scripting/1069890.htm>>
>>
http://forums.techarena.in>>
>
>