Jump to content

LDAP user info


Recommended Posts

I have been reading all the LDAP Fourm info . But unable to actually pull information from the server . Do I have to be logged onto that machine to get the info that I request. I would like to pll the information remotely if possible.

Thanks

Link to comment
Share on other sites

  • Developers

I have been reading all the LDAP Fourm info . But unable to actually pull information from the server . Do I have to be logged onto that machine to get the info that I request. I would like to pll the information remotely if possible.

Thanks

Could you be more specific what information you want retrieve?

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

  • Developers

Computer Name

User Name

Full Name

IP

Email

Mac

So far that if possible... But eventually as much as I can obtain..

Thanks

Do you want to get this info from the AD or the PC itself?

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

  • Developers

Something like this should work. You need to add the fields you require but it gets you started.

Jos

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

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

Something like this should work. You need to add the fields you require but it gets you started.

Jos

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

16) : ==> The requested action with this object has failed.:

Local $objRecordSet = $objCommand.Execute

Local $objRecordSet = $objCommand.Execute^ ERROR

Link to comment
Share on other sites

  • Developers

I guess you are asking if we can help you?

Add the comerror handler as described in the helpfile to get the "real" error description.

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

I guess you are asking if we can help you?

Add the comerror handler as described in the helpfile to get the "real" error description.

JoS: All I would like is a basic script to connect to AD and list PCs with names and other info .. I'm not trying to bve short with you..

I'm unsure how to work with com error handling .

Thanks again

Link to comment
Share on other sites

  • Developers

JoS: All I would like is a basic script to connect to AD and list PCs with names and other info .. I'm not trying to bve short with you..

I'm unsure how to work with com error handling .

Thanks again

I am not trying to make your live difficult either but it has been a little like pulling teeth trying to help you and I also think people should do a part themselves to ensure they know what they are doing. The ComErrorEvent handler is described in the helpfile so I am not going to work it out for you.

By the way:The script I gave is from a working script but I just removed the AD name and retrieves all USer objects from the AD and dumps them into a csv file.

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

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