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.

Get User Properties

This script will make a CSV file of the available properties of a ADSI User Object.
AddExtender("wwads34i.dll")
; samAccountName of user of interest
MyUser = "brendan"
MANDATORY  = 1
OPTIONAL   = 2
MANANDOPT  = 3

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%))")

file=FileOpen("c:\ADSI %MyUser%.csv","WRITE")
; Get mandatory properties of object.
sList = dsGetPropName(UserPath,MANDATORY)
If sList != ""
   count=ItemCount(sList,@TAB)
   FileWrite(file,"Mandatory Property Value(s)")
   For i = 1 To count
      name=ItemExtract(i,sList,@TAB)
      ErrorMode(@OFF)
      props=dsGetProperty(UserPath,name)
      StrReplace(props,@TAB,",")
      ErrorMode(@CANCEL)
      FileWrite(file,StrCat(name,",",props))
   Next
EndIf 

FileWrite(file,"")
count=""

; Get optional properties of object.
sList = dsGetPropName(UserPath, OPTIONAL)
If sList != ""
   count=ItemCount(sList,@TAB)
   FileWrite(file,"Optional Property Value(s)")
   For i = 1 To count
      name=ItemExtract(i,sList,@TAB)
      ErrorMode(@OFF)
      props=dsGetProperty(UserPath,name)
      StrReplace(props,@TAB,",")
      ErrorMode(@CANCEL)
      FileWrite(file,StrCat(name,",",props))
      Next
EndIf  
FileClose(file)
Message("See file","c:\ADSI %MyUser%.csv")

Article ID:   W15814
File Created: 2004:03:30:15:40:58
Last Updated: 2004:03:30:15:40:58