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 LDAP CDO
plus
plus

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

List Groups a User Belongs To

 Keywords: List Groups User Belongs To member Memberof Type GLobal Local Builtin Universal dsGetUsersGrps

; Notice the server-less ADSI path.
;  Get the domain DN with a server-less ADSI path.
objRootDSE  = GetObject("LDAP://rootDSE")
domain = objRootDSE.Get("defaultNamingContext")
sUsersPath = "LDAP://cn=users,":domain
users =  GetObject(sUsersPath) ;Get object Users container
lValues = ""
ForEach obj In users
   If obj.Class == "user"
    lValues = lValues:@TAB:"LDAP://CN=":obj.CN:";CN=Users;":domain
   EndIf
Next
; List all objects in the user container of the default domain.
UserPath =  AskItemlist("Objects in Users", StrTrim(lValues), @TAB, @UNSORTED , @SINGLE )

;The groupType attribute returns the type of group. However the returned value is in RAW format.
;Possible return values below:
;
;-2147483646 ~ Global Security Group
;-2147483644 ~ Local Security Group
;-2147483643 ~ BuiltIn Group
;-2147483640 ~ Universal Security Group
;
;2 ~ Global Distribution Group
;4 ~ Local Distribution Group
;8 ~ Universal Distribution Group
;
usr = GetObject(UserPath) ; Bind to user object
groups = ""
ForEach grp In usr.Groups
    groups = groups: @TAB: grp.GroupType: ":":grp.Name
Next
AskItemlist("Groups ":UserPath:" is member of", StrTrim(groups), @TAB, @UNSORTED, @SINGLE)
usr = 0

Article ID:   W18052
Filename:   List Groups a User Belongs To.txt
File Created: 2013:01:04:14:42:14
Last Updated: 2013:01:04:14:42:14