Hello,
I've seen the codes for getting info on the current user logged in but what I need to do is query for a specific user and I can't seem to locate the proper example...
any ideas?

[Solved]LDAP query for a specific user
Started by
frescalus
, Jul 16 2010 01:17 PM
13 replies to this topic
#1
-
Posted 16 July 2010 - 01:17 PM
![[Solved]LDAP query for a specific user: post #1](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
using your subject as is within google i found this wheihc is command line which you should be able toe xecute with or without ahk
<!-- m -->http://technet.micro... ... UsingLDIFE<!-- m -->
<!-- m -->http://technet.micro... ... UsingLDIFE<!-- m -->
#3
-
Posted 19 July 2010 - 12:17 PM
![[Solved]LDAP query for a specific user: post #3](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
Never lose.
WIN or LEARN.
WIN or LEARN.
don't I feel dumb, I didn't think to use the subject as search criteria in google... thanks tank I'll check it out
#4
-
Posted 19 July 2010 - 12:32 PM
![[Solved]LDAP query for a specific user: post #4](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
I've been trying all sorts of things, I'm missing something obviously
is there any way to use
in COM and get it to work? (with my criteria of course)
is there any way to use
ldap://ldap.example.com/dc=example,dc=com??sub?(sn=Jensen)
in COM and get it to work? (with my criteria of course)
#5
-
Posted 20 July 2010 - 05:41 PM
![[Solved]LDAP query for a specific user: post #5](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
bump
I have this that does work for me using it in ahk
Any help to convert it to COM? My attempts at it are failing
I have this that does work for me using it in ahk
Dim firstName, lastName lastName = "Doe" firstName = "Jane" Set conn = createobject("ADODB.Connection") conn.provider = "ADsDSOObject" conn.open "Active Directory Provider" query = "<LDAP://myLDAP>;(&(objectclass=user)(objectcategory=person)(sn=" & lastName & ")(&(givenName=" & firstName & ")));distinguishedname,cn,employeeid,mail,givenname,sn,middlename,samaccountname,displayname,department,division,bhnadpmanagerid,manager;subtree" Set cmd = CreateObject("ADODB.Command") cmd.ActiveConnection = conn cmd.Properties("SearchScope") = 2 cmd.Properties("Page Size") = 500 cmd.CommandText = query Set rs = cmd.Execute While not rs.eof msgbox rs.Fields("department").Value rs.MoveNext Wend
Any help to convert it to COM? My attempts at it are failing
#6
-
Posted 21 July 2010 - 12:33 PM
![[Solved]LDAP query for a specific user: post #6](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
Everything up to including ActiveConnection is fine, everything below just isn't working right and gets errors....
COM_Init() lastName = Doe firstName = Jane connProv := "ADsDSOObject" connOpen := "Active Directory Provider" Query := "<LDAP://corp>;(&(objectclass=user)(objectcategory=person)(sn=" lastName ")(&(givenName=" firstName ")));distinguishedname,cn,employeeid,mail,givenname,sn,middlename,samaccountname,displayname,department,division,bhnadpmanagerid,manager;subtree" oConn := COM_CreateObject("ADODB.Connection") oComm := COM_CreateObject("ADODB.Command") COM_Invoke(oConn, "Provider", connProv) COM_Invoke(oConn, "Open", connOpen) COM_Invoke(oComm, "ActiveConnection", "+" . oConn) COM_Invoke(oComm, "Properties", "SearchScope", "2") COM_Invoke(oComm, "Properties", "Page Size", "500") COM_Invoke(oComm, "ComandText", Query) result := COM_Invoke(oComm, "Execute") MsgBox % result COM_Invoke(oConn, "Close") COM_Release(oConn) COM_Release(oComm) COM_Term()
#9
-
Posted 22 July 2010 - 01:42 PM
![[Solved]LDAP query for a specific user: post #9](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
ok I got something that works, after working through this, I found my first mistake which was a mispelling of the word Command...
Here's what I came up with...and it got me the results...
I had to change the query statement though to sql...the other way I had it would give me Commandtext errors....
Is this pretty accurate code wise? I want to make sure I'm spot on before I mark this solved.
EDIT: Update code to for multiple matches...
EDIT2: I figured out what was wrong with my ldap syntax and fixed it...
Here's what I came up with...and it got me the results...
I had to change the query statement though to sql...the other way I had it would give me Commandtext errors....
Is this pretty accurate code wise? I want to make sure I'm spot on before I mark this solved.
COM_init() COM_CoInitialize() lastName = Doe firstName = Jane connProv := "ADsDSOObject" connOpen := "Active Directory Provider" Query := "<LDAP://myldapserver>;(&(objectclass=user)(objectcategory=person)(&(sn=" lastName ")(givenName=" firstName ")));distinguishedname,cn,employeeid,mail,givenname,sn,middlename,samaccountname,displayname,department,division,bhnadpmanagerid,manager;subtree" oConn := COM_CreateObject("ADODB.Connection") oComm := COM_CreateObject("ADODB.Command") COM_Invoke(oConn, "Provider", connProv) COM_Invoke(oConn, "Open", connOpen) COM_Invoke(oComm, "ActiveConnection", "+" . oConn) COM_Invoke(oComm, "Properties", "SearchScope", "2") COM_Invoke(oComm, "Properties", "Page Size", "500") COM_Invoke(oComm, "CommandText", Query) adoExecute := COM_Invoke(oComm, "Execute") Loop { If COM_Invoke(adoExecute, "EOF") Break exFields := COM_Invoke(adoExecute, "Fields") exField := COM_Invoke(exFields, "Item", "cn") result .= COM_Invoke(exField, "Name") . ": " . COM_Invoke(exField, "Value") . "`r`n" COM_Invoke(adoExecute, "MoveNext") COM_Release(exField) } MsgBox % result COM_Invoke(oConn, "Close") COM_Release(exFields) COM_Release(exField) COM_Release(oConn) COM_Release(oComm) COM_CoUnInitialize() COM_Term()
EDIT: Update code to for multiple matches...
EDIT2: I figured out what was wrong with my ldap syntax and fixed it...
#10
-
Posted 22 July 2010 - 06:44 PM
![[Solved]LDAP query for a specific user: post #10](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
Sorry for taking so long to follow up but I knew you could do it
#12
-
Posted 23 July 2010 - 12:22 PM
![[Solved]LDAP query for a specific user: post #12](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
Never lose.
WIN or LEARN.
WIN or LEARN.
Hi
Looking at the script posted above, how do I send
Properties - User ID, Password & Encrypt Password.
When I try that I get:
Thanks
Looking at the script posted above, how do I send
Properties - User ID, Password & Encrypt Password.
COM_Invoke(oComm, "Properties", "User ID", "username") COM_Invoke(oComm, "Properties", "Password", "password") COM_Invoke(oComm, "Properties", "Encrypt Password", "False")
When I try that I get:
Function Name: "Properties"
ERROR: Invalid number of parameters. (0x8002000E)
ERROR2: Exception occurred. (0x80020009)
Will Continue ?
Thanks

#13
-
Posted 27 October 2010 - 10:15 AM
![[Solved]LDAP query for a specific user: post #13](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)