WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADSI
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Check if User Account Object Exists

 Keywords: User Exist Account Check 

Here is some sample code I put together that uses the ADSI extender to check if the user exists using dsIsObject.
AddExtender("WWADS44I.DLL")
;
; samAccountName of user of interest
;
MyUser = "deanad" ;!!!! MODIFY TO FIT YOUR NEEDS
ServerDn=dsGetProperty("LDAP://rootDSE", "serverName")
ServerName=ItemExtract(1, ServerDn, ",")
ServerName=ItemExtract(2, ServerName, "=")
ServerDn=dsGetProperty("LDAP://rootDSE", "defaultNamingContext")
ServerPath="LDAP://%ServerName%/%ServerDN%"
UserPath=dsFindPath(ServerPath, "(&(objectCategory=person)(sAMAccountName=%MyUser%))")
;
; Check if user exists
;
If dsIsObject(UserPath )   
   Message(UserPath, "User Exists.")
Else   
   Message(UserPath, "User Does NOT exist.")
EndIf

Article ID:   W17363
File Created: 2008:04:10:15:08:24
Last Updated: 2008:04:10:15:08:24