Jump to content

Reading a Group to see who is in it


Recommended Posts

Here you go. The only tricky thing is that you have to know the DN (distinguished name) of the group you're trying to enumerate, in this case I'm using "cn=Administrators,cn=Builtin, "

;  Bind to Active Directory;
$objRootDSE = ObjGet("LDAP://RootDSE")
$strDNSDomain = $objRootDSE.Get("DefaultNamingContext")

;  Get the Builtin Administrators group
$strContainer = "cn=Administrators,cn=Builtin, "
$objGroup = ObjGet ("LDAP://"& $strContainer & $strDNSDomain)
$objGroup.getInfo()

$adminlist = ""
$arrMemberOf = $objGroup.GetEx("member")
For $strMember in $arrMemberOf
    $user = ObjGet ("LDAP://"&$strMember)
    if isobj($user) Then $adminlist &= $user.sAMAccountName & @crlf
Next
    
msgbox(0,"Admin List",$adminlist)

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...