OK - here is the version 2 - hopefully thats' what you're looking for (to
test for a paricular user, simply its sAMAccountname at the command prompt
as the parameter of the script:
Btw. while Richard's remark is sound, using objectCategory as the query
filter has its purpose (performance benefits) - but if you suspect you might
be running into name clashes with other object types, feel free to exclude
it...
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
sName1 = WScript.Arguments(0)
sName2 = sName1
bFound = False
iCount = 0
While bFound = False
oCommand.CommandText = _
"SELECT * FROM 'LDAP://dc=yourDomainName,dc=local' WHERE
objectCategory='user'" &_
" AND sAMAccountName='" & sName2 & "'"
Set oRecordSet = oCommand.Execute
If oRecordset.RecordCount > 0 Then
iCount = iCount + 1
sName2 = Left(sName2, Len(sName1)) & iCount
Else
bFound = True
WScript.Echo sName2
End If
Wend
hth
Marcin
"thehump" <> wrote in message
news:...
>
> Thanks for the help, but i have a few questions. Shouldn't it be
> WScript.Echo sOrgName? Also, i don't want the return value to have a
> number at the end if it isn't a duplicate. How can that be done?
>
>
> --
> 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
>