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.

List Users with Multiple Attributes

 Keywords: dsFindPath LDAP Query AD ADSI Active Directory List Users One Or More Multiple Attributes objectCategory

Question:

I want to get the list of all users who have 1 (or more) of these attributes defined: extensionAttribute2, extensionAttribute3, extensionAttribute4

Answer:

; Notice that each argument is in its own set of parentheses. The entire LDAP statement must be encompassed in a main set of parentheses. The logical AND & operator means that each argument must be
; true for this filter to apply to your object in question.
; The logical OR | operator means that any argument must be true for this filter to apply to your object in question.

;Get the list of all users who have 1 (or more) of these attributes : extensionAttribute2,extensionAttribute3,extensionAttribute4
sSearch = "(&(objectCategory=user)(|((extensionAttribute2=*)(extensionAttribute3=*)(extensionAttribute4=*))))"

;Load Appropriate Extender
If WinMetrics(-2) == 3 Then AddExtender("WWADS64I.DLL") ; 64-bit
Else AddExtender("WWADS44I.DLL") ; 32-bit

; Restrict the search to one domain.
sAdsiPath = "LDAP://domain/dc=sample,dc=com"
Result= dsFindPath(sAdsiPath,  sSearch)

sAdsiUserPath = AskItemlist("Result", Result, @TAB, @UNSORTED, @SINGLE ,@TRUE )

extensionAttribute2 = dsGetProperty(sAdsiUserPath, "extensionAttribute2")
extensionAttribute3 = dsGetProperty(sAdsiUserPath, "extensionAttribute3")
extensionAttribute4 = dsGetProperty(sAdsiUserPath, "extensionAttribute4")

Pause(sAdsiUserPath,'extensionAttribute2 = ':extensionAttribute2:@CRLF:'extensionAttribute3 = ':extensionAttribute3:@CRLF:'extensionAttribute4 = ':extensionAttribute4)

Exit


Check for attributes that are not set.

;Get the list of all users that are Missing 1 (or more) of these attributes : extensionAttribute2,extensionAttribute3,extensionAttribute4
;(attribute=*) = set
;(!attribute=*) = not set

sSearch = "(&(objectCategory=user)(|(!extensionAttribute2=*)(!extensionAttribute3=*)(!extensionAttribute4=*)))"

;Load Appropriate Extender
If WinMetrics(-2) == 3 Then AddExtender("WWADS64I.DLL") ; 64-bit
Else AddExtender("WWADS44I.DLL") ; 32-bit

; Restrict the search to one domain.
sAdsiPath = "LDAP://domain/dc=sample,dc=com"
sAdsiPath = "LDAP://DOGWOOD/dc=wwwinc,dc=local"
Result= dsFindPath(sAdsiPath,  sSearch)

sAdsiUserPath = AskItemlist("Result", Result, @TAB, @UNSORTED, @SINGLE ,@TRUE )

extensionAttribute2 = dsGetProperty(sAdsiUserPath, "extensionAttribute2")
extensionAttribute3 = dsGetProperty(sAdsiUserPath, "extensionAttribute3")
extensionAttribute4 = dsGetProperty(sAdsiUserPath, "extensionAttribute4")

Pause(sAdsiUserPath,'extensionAttribute2 = ':extensionAttribute2:@CRLF:'extensionAttribute3 = ':extensionAttribute3:@CRLF:'extensionAttribute4 = ':extensionAttribute4)

Exit

Article ID:   W17534
Filename:   List Users with Multiple Attributes.txt
File Created: 2012:10:26:13:17:42
Last Updated: 2012:10:26:13:17:42