|
-
Aug 3rd, 2005, 10:10 AM
#1
Thread Starter
Lively Member
How to retrieve All info about AD Users ??
Hi,
i want to get all info about a certain user in the Active Directory,
i tried to use the following code:
VB Code:
Set oContainer = GetObject("WinNT://" + "ITAcademy.com")
For Each oIADs In oContainer
If (oIADs.Class = "User") Then
Set oUser = oIADs
When i use this code it can give me small portion of info such as Full Name, but i cant get the mail address, cause i have an error as follows:
VB Code:
' The directory property cannpt be found in the cache
googlin around i found the winNt objects doesn't support such info, so i need to use LDAP code, is there any sample around?
thanks,
-
Aug 3rd, 2005, 10:21 AM
#2
Re: How to retrieve All info about AD Users ??
-
Aug 3rd, 2005, 01:57 PM
#3
Thread Starter
Lively Member
Re: How to retrieve All info about AD Users ??
Well, thank you for the article, but do u know what is the attribute of the email address ie. rs("Mail")???
-
Aug 3rd, 2005, 02:00 PM
#4
Re: How to retrieve All info about AD Users ??
 Originally Posted by L1nuxVb
Well, thank you for the article, but do u know what is the attribute of the email address ie. rs("Mail")???
No, I found that after doing a Google of "ldap vb6"
Maybe there is other stuff out there that would explain more. I'll see what I can find.
-
Aug 3rd, 2005, 03:28 PM
#5
Thread Starter
Lively Member
Re: How to retrieve All info about AD Users ??
Well , searching around i found something that worked
VB Code:
Dim conn As New ADODB.Connection
Dim strRS As String
Dim RS As ADODB.Recordset
Dim strconn As String
Private Sub Form_Load()
'Set Conn = Server.CreateObject("ADODB.Connection")
'Set RS = Server.CreateObject("ADODB.Recordset")
'Conn.Provider = "ADsDSOObject"
'strconn = "Active Directory Provider"
conn.Open _
"Data Source=Active Directory Provider;Provider=ADsDSOObject"
strRS = "SELECT name, mail FROM 'LDAP://head.com' WHERE objectClass = 'user' "
Set RS = conn.Execute(strRS)
While RS.EOF = False
MsgBox ("Name: " & RS("name") & " ,e-mail: " & RS("mail"))
RS.MoveNext
Wend
End Sub
-
Mar 13th, 2008, 04:18 AM
#6
PowerPoster
Re: How to retrieve All info about AD Users ??
 Originally Posted by L1nuxVb
Well , searching around i found something that worked
VB Code:
Dim conn As New ADODB.Connection
Dim strRS As String
Dim RS As ADODB.Recordset
Dim strconn As String
Private Sub Form_Load()
'Set Conn = Server.CreateObject("ADODB.Connection")
'Set RS = Server.CreateObject("ADODB.Recordset")
'Conn.Provider = "ADsDSOObject"
'strconn = "Active Directory Provider"
conn.Open _
"Data Source=Active Directory Provider;Provider=ADsDSOObject"
strRS = "SELECT name, mail FROM 'LDAP://head.com' WHERE objectClass = 'user' "
Set RS = conn.Execute(strRS)
While RS.EOF = False
MsgBox ("Name: " & RS("name") & " ,e-mail: " & RS("mail"))
RS.MoveNext
Wend
End Sub
Hi L1nuxVb tks for share!
I am a newbie, sure....
Have idea if existis a list of complete object to retrive other info from LDAP query.?
You know only Name and Mail?
Tks from Italy.
Sal.
-
Mar 13th, 2008, 10:31 AM
#7
Re: How to retrieve All info about AD Users ??
 Originally Posted by luca90
Have idea if existis a list of complete object to retrive other info from LDAP query.?
Like what?
And, you should start your own thread for this question.
-
Mar 13th, 2008, 12:22 PM
#8
Re: How to retrieve All info about AD Users ??
Hes asking if there is a complete listing of the objects information instead of just the two.
I supose if you use the "*" in your select query and reference thee field index positions instead of their names you can return and list out all available info.
Code:
strRS = "SELECT * FROM 'LDAP://head.com' WHERE objectClass = 'user' "
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 13th, 2008, 03:27 PM
#9
PowerPoster
Re: How to retrieve All info about AD Users ??
 Originally Posted by RobDog888
Hes asking if there is a complete listing of the objects information instead of just the two.
I supose if you use the "*" in your select query and reference thee field index positions instead of their names you can return and list out all available info.
Code:
strRS = "SELECT * FROM 'LDAP://head.com' WHERE objectClass = 'user' "
Hi RobDog888 happy to see you on my one post!
Yes ok for query with "*" ....
but tell me... wath are the other object disponible:
computermname, userid...
have a lists?
-
Jan 15th, 2010, 08:23 PM
#10
Member
Re: How to retrieve All info about AD Users ??
 Originally Posted by luca90
Hi L1nuxVb tks for share!
I am a newbie, sure....
Have idea if existis a list of complete object to retrive other info from LDAP query.?
You know only Name and Mail?
Tks from Italy.
Sal.
Hmmm this seams quite useful, i need to make it only search for a pre-specified login name and then state the name and mail and so on. Anyone know how to?
br,
R
-
Jan 16th, 2010, 01:09 PM
#11
Member
Re: How to retrieve All info about AD Users ??
 Originally Posted by L1nuxVb
Well , searching around i found something that worked
VB Code:
Dim conn As New ADODB.Connection Dim strRS As String Dim RS As ADODB.Recordset Dim strconn As String Private Sub Form_Load() 'Set Conn = Server.CreateObject("ADODB.Connection") 'Set RS = Server.CreateObject("ADODB.Recordset") 'Conn.Provider = "ADsDSOObject" 'strconn = "Active Directory Provider" conn.Open _ "Data Source=Active Directory Provider;Provider=ADsDSOObject" strRS = "SELECT name, mail FROM 'LDAP://head.com' WHERE objectClass = 'user' " Set RS = conn.Execute(strRS) While RS.EOF = False MsgBox ("Name: " & RS("name") & " ,e-mail: " & RS("mail")) RS.MoveNext Wend End Sub
Something weird happed to the quotation in the above post, well i meant to quote this one anyhow. 
Anyone know how you make this work for grabbing full name and email from a specified login name only. not looping through the whole ad?
Cheers!
/Rambit
EDIT: Clarifying the question
Last edited by rambit; Jan 17th, 2010 at 03:20 PM.
-
Jan 17th, 2010, 05:10 PM
#12
Re: How to retrieve All info about AD Users ??
 Originally Posted by rambit
Anyone know how you make this work for grabbing full name and email from a specified login name only. not looping through the whole ad?
Lets pretend the username you need the name and mail for is "IamRambit" in AD.
Try the below syntax.
VB Code:
strRS = "SELECT name, mail FROM 'LDAP://head.com' WHERE objectClass = 'user' AND sAMAccountName='IamRambit' "
Let me know if that worked.
p.s: Make sure you replace IamRambit with the actual <userName> or variable containing the username you need the data for.
Last edited by Optional; Jan 18th, 2010 at 05:02 AM.
Reason: Updated Code Tag to VBCode
Kind Regards,
Optional
If you feel this post has helped in answering your question please return the favour and Rate this post.
If your problem has been solved and your question has been answered mark the thread as [RESOLVED] by selecting the Thread Tools menu option at the top and clicking the Mark Thread Resolved menu item.
VB6 - (DataGrid) Get the Row selected with the right mouse button
-
Jan 20th, 2010, 10:52 AM
#13
Member
Re: How to retrieve All info about AD Users ??
Hi optional!
You seem to be my LDAP savior 
Thanks again, and it did work flawlessly! May i ask if this is a possible method for listing all security groups on a user as well?
Thanks a milion m8!
br,
Rambit
-
Jan 20th, 2010, 06:53 PM
#14
Re: How to retrieve All info about AD Users ??
 Originally Posted by rambit
May i ask if this is a possible method for listing all security groups on a user as well?
Declare some extra extra variables:
Change your Query to:
VB Code:
strRS = "SELECT name, mail, adsPath FROM 'LDAP://head.com' WHERE objectClass = 'user' AND objectCategory='person' AND sAMAccountName='IamRambit' "
When you set your RecordSet object you now have also adsPath as a 3rd field returned.
We are going to use it to extract the groups this user is part of like this:
VB Code:
Set RS = conn.Execute(strRS) RS.MoveFirst While RS.EOF = False Set oUser = GetObject(RS("adsPath")) For Each group In oUser.Groups MsgBox group.Name Next RS.MoveNext Wend
The group names are formatted like this "CN=<groupName>", just trim of the "CN=" part.
I'm not 100% sure if this is the only way to extract the groups but I hope this will work for you anyway.
Kind Regards,
Optional
If you feel this post has helped in answering your question please return the favour and Rate this post.
If your problem has been solved and your question has been answered mark the thread as [RESOLVED] by selecting the Thread Tools menu option at the top and clicking the Mark Thread Resolved menu item.
VB6 - (DataGrid) Get the Row selected with the right mouse button
-
Jan 21st, 2010, 03:10 AM
#15
Member
Re: How to retrieve All info about AD Users ??
Thanks alot optional, it worked like a charm! 
best regards,
Rambit
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|