Jump to content
Sign in to follow this  
Ghost21

LDAP user info

Recommended Posts

Ghost21

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

Share this post


Link to post
Share on other sites
Jos

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?

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Ghost21

Could you be more specific what information you want retrieve?

Computer Name

User Name

Full Name

IP

Email

Mac

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

Thanks

Share this post


Link to post
Share on other sites
Jos

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


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Ghost21

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

Jos

From Active Directory

Share this post


Link to post
Share on other sites
Jos

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

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Ghost21

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

Share this post


Link to post
Share on other sites
Jos

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

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Ghost21

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

Share this post


Link to post
Share on other sites
Jos

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

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.