Jump to content

Recommended Posts

Posted

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

Posted

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]

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
  • Recently Browsing   0 members

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