Jump to content

Browse Active Directory


 Share

Recommended Posts

  • Developers

Hi

is it possible to browse the active directory an pick a group into a variable? i could not find any solution for this.

regards

Not sure what you are asking but there are several scripts/udfs posted that will work with AD users/groups using the ADSI LDAP/WINNT Com objects.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Not sure what you are asking but there are several scripts/udfs posted that will work with AD users/groups using the ADSI/WINNT Com objects.

Jos

Hi Jos

i will manually pick an existing group name from ad into a variable. like this: open ad window, search an mark the group, ok and then the group is in a variable.

i could not find any reason in the forum.

regards

Link to comment
Share on other sites

  • Developers

This is an example of a script that enumerates all users and write them to a file, maybe that gives you an Idea how to start coding your script.

I have no domain to my disposal anymore thus cannot test and change it to show groups.

Func _EnumUsers()
    Local $objCommand = ObjCreate("ADODB.Command")
    Local $objConnection = ObjCreate("ADODB.Connection")
    $objConnection.Provider = "ADsDSOObject"
    $objConnection.Open ("Active Directory Provider")
    $objCommand.ActiveConnection = $objConnection
    Local $strBase = "<GC://dc=MyDom,dc=Inc>"
    Local $strFilter = "(&(objectCategory=person)(objectClass=user)(sAMAccountName=*))"
    Local $strAttributes = "cn,sAMAccountName,displayName,sn,distinguishedName"
    Local $strQuery = $strBase & ";" & $strFilter & ";" & $strAttributes & ";subtree"
    $objCommand.CommandText = $strQuery
    $objCommand.Properties ("Page Size") = 100
    $objCommand.Properties ("Timeout") = 30
    $objCommand.Properties ("Cache Results") = False
    $ADS_SCOPE_SUBTREE = 2
    $objCommand.Properties ("searchscope") = $ADS_SCOPE_SUBTREE
    Local $objRecordSet = $objCommand.Execute
    While Not $objRecordSet.EOF
;~      $strName = $objRecordSet.Fields ("sAMAccountName").Value
;~      $strCN = $objRecordSet.Fields ("cn").value
;~      $strdisplayName = $objRecordSet.Fields ("displayName").value
;~      $strSN = $objRecordSet.Fields ("SN").value
;~      $strdistinguishedName = $objRecordSet.Fields ("distinguishedName").value
;~      $strSID = $objRecordSet.Fields ("distinguishedName").value
        FileWriteLine("Users.txt",$objRecordSet.Fields ("sAMAccountName").Value)
        $objRecordSet.MoveNext
    WEnd
    $objConnection.Close
    $objConnection = ""
    $objCommand = ""
    $objRecordSet = ""
EndFunc ;==>_EnumUsers
Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...