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

Samples from Users

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

ADSI Primer


This is a little ditty that i cooked up, as i couldnt figure out what properties were associated with user objects, nor what there values should be. it also helped shed some light on what the proper format of things like HomeMDB, HomeMTA and other things that need to be set for exchange mailboxes. either way it will get the attributes for the specified user. i hope this might help any newcomers to ADSI scripting.

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)
Run("c:\ADSI %MyUser%.csv","")


Article ID:   W15823
File Created: 2004:03:30:15:41:00
Last Updated: 2004:03:30:15:41:00