Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


Sample Code to Return all of the Attributes (ex. Property Names) that you can Populate on an AD Account

Keywords:   attributes AD account  property names

This is a modification to a previously published script. It will return all of the attributes that you can populate on an AD user account. You will still have to figure out what the field they display in or what they are exactly. Eventually I'll have a list of what they're associated with.

1. Set the login name

2. Change the LDAP path to a valid one in your environment.

------------------------------------
AddExtender("WWADS34I.DLL")

; Set credentials.
Account="ACCOUNT WITH ADMIN ACCESS"
pwd=AskPassword ("Password", "Enter the Password for %Account%")

a=dsSetCredent(Account, pwd)


; Define some constants.
MANDATORY = 1
OTIONAL = 2
MANANDOPT = 3

; An Active Directory example.

; The user object "Russ T Gate" on the "win2000" server.

; Make sure the following on one line
sAdsiPath = "LDAP://win2000/CN=Russ T Gate,CN=Users,DC=win2000,DC=windowware,DC=com"

Output=FileOpen("C:\temp\out.csv","WRITE")
FileWrite(Output,"Type,Property Name,Value")


; Get mandatory properties of object.
sList = dsGetPropName(sAdsiPath, MANDATORY)
if sList != ""
count=ItemCount(sList,@TAB)
For x=1 to count
item=ItemExtract(x,sList,@TAB)
val=dsGetProperty(sAdsiPath, item)
FileWrite(Output,"MANDATORY,%item%,%val%")
Next
endif 

; Get optional properties of object.
sList = dsGetPropName(sAdsiPath, OTIONAL)
if sList != ""
count=ItemCount(sList,@TAB)
For x=1 to count
item=ItemExtract(x,sList,@TAB)
val=dsGetProperty(sAdsiPath, item)
Data=StrCat("OPTIONAL",",",item,",",val)
FileWrite(Output,Data)
Next
endif 


; Get all properties of object.
;sList = dsGetPropName(sAdsiPath, MANANDOPT )
;if sList != "" 
; sList = strreplace(sList,@TAB, @CRLF)
; message("All Property names. ", sList)
; FileWrite(Output," ")
;FileWrite(Output," ")
;FileWrite(Output,"All Property names. ")
;FileWrite(Output,"--------------------------")
;FileWrite(Output,sList)
;endif 

FileClose(Output)
Run("Excel.exe","C:\temp\out.csv") 

Available User Account attributes see:
http://msdn.microsoft.com/library/en-us/adschema/ad/win2k_c_user.asp
List of all Schema Attributes and info on each:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adschema/ad/win2k_entry_attributes_all.asp ttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/adschema/ad/win2k_entry_attributes_all.asp