Sign in to follow this  
Followers 0
Alan D. Ayers

Reading a Group to see who is in it

2 posts in this topic

I want to read the group and see who is in it. I already have the code to add users to my SQL Server database so all I need to do is see if they should be in SQL by getting what users are in the Group.

Any help is greatly appreciated. Thanks

Alan

Share this post


Link to post
Share on other sites



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]

Share this post


Link to post
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
Sign in to follow this  
Followers 0