i need a simple(?) script that will take an AD user as an argument and create
a list of ALL AD attributes that apply to users, and if the attribute is used
also list the value of the attribute. if the attribute is empty i still have
to list it, but there will just be no value. can anyone point me in the right
direction? thank you

Re: need to get AD attributes using vbscript. please help by Ato

Ato
Fri Jul 22 00:16:20 CDT 2005

Hello,

The script below should be a good starting point.

You might still need to augment the SELECT statement to take care of the other data types
not represented but might be in your AD implementation (See CONSTANTS section).

HTH,
Ato
(Watch out for those pesky line breaks)
---------------------------------------------------------------
userCN = "John Smith"
Set user = GetObject("LDAP://CN=" & userCN & ",OU=Users,DC=FOO,DC=BAR,DC=COM")

user.GetInfo
propCount = user.PropertyCount
For p = 0 to propCount - 1
Set propEntry = user.Item(p)
dispVal = ""
For each propVal in propEntry.Values
SELECT CASE propVal.ADsType
CASE ADSTYPE_DN_STRING : dispVal = propVal.DNString
CASE ADSTYPE_CASE_EXACT_STRING : dispVal = propVal.CaseExactString
CASE ADSTYPE_CASE_IGNORE_STRING : dispVal = propVal.CaseIgnoreString
CASE ADSTYPE_PRINTABLE_STRING : dispVal = propVal.PrintableString
CASE ADSTYPE_NUMERIC_STRING : dispVal = propVal.NumericString
CASE ADSTYPE_BOOLEAN : dispVal = CStr(propVal.Boolean)
CASE ADSTYPE_INTEGER : dispVal = propVal.Integer
CASE ADSTYPE_TIMESTAMP : dispVal = CStr(propVal.Timestamp)
CASE ADSTYPE_UTC_TIME : dispVal = CStr(propVal.UTCTime)
END SELECT
Wscript.echo ">>", propEntry.name, "=", dispVal
Next
Next

Const ADSTYPE_DN_STRING = 1
Const ADSTYPE_CASE_EXACT_STRING = 2
Const ADSTYPE_CASE_IGNORE_STRING = 3
Const ADSTYPE_PRINTABLE_STRING = 4
Const ADSTYPE_NUMERIC_STRING = 5
Const ADSTYPE_BOOLEAN = 6
Const ADSTYPE_INTEGER = 7
Const ADSTYPE_OCTET_STRING = 8
Const ADSTYPE_UTC_TIME = 9
Const ADSTYPE_LARGE_INTEGER = 10
Const ADSTYPE_PROV_SPECIFIC = 11
Const ADSTYPE_OBJECT_CLASS = 12
Const ADSTYPE_CASEIGNORE_LIST = 13
Const ADSTYPE_OCTET_LIST = 14
Const ADSTYPE_PATH = 15
Const ADSTYPE_POSTALADDRESS = 16
Const ADSTYPE_TIMESTAMP = 17
Const ADSTYPE_BACKLINK = 18
Const ADSTYPE_TYPEDNAME = 19
Const ADSTYPE_HOLD = 20
Const ADSTYPE_NETADDRESS = 21
Const ADSTYPE_REPLICAPOINTER = 22
Const ADSTYPE_FAXNUMBER = 23
Const ADSTYPE_EMAIL = 24
Const ADSTYPE_NT_SECURITY_DESCRIPTOR = 25
Const ADSTYPE_UNKNOWN = 26

"jim d" <jimd@discussions.microsoft.com> wrote in message
news:5270A3C5-6EAD-490F-9FA6-725622F0FB9E@microsoft.com...
> i need a simple(?) script that will take an AD user as an argument and create
> a list of ALL AD attributes that apply to users, and if the attribute is used
> also list the value of the attribute. if the attribute is empty i still have
> to list it, but there will just be no value. can anyone point me in the right
> direction? thank you