473,397 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

How do you grab information with VB from Active Directory?

anoble1
245 128KB
Hi,

I have a program that I made that can grab all kinds of information from a PC using WMI thanks to Rabbit. I can just type in the remote PC's name or IP and I can get all kinds of info. But now I am looking to get the userID's information. I know very little about Active Directory, but that is where I am told all the user's info is located. Can anyone help me get started on some code that can access the active directory and pull user info? Such as Phone, Location, Manager, Name etc..
Mar 10 '13 #1

✓ answered by ADezii

The following Code will illustrate the basic concepts on how to extract Information from Active Directory. I cal also supply additional AD Variables if you so desire.
Expand|Select|Wrap|Line Numbers
  1. 'First, you must set a Reference to the Active DS Type Library
  2. Dim sysInfo As Object
  3. Dim oUser As Object
  4. Dim oPath As Object         'Path Class in the ActiveDs Library
  5. Dim intUser As Integer
  6. Dim strLName As String
  7. Dim strFName As String
  8. Dim strUserName As String
  9. 'Dim strEMail As String
  10.  
  11. Set sysInfo = CreateObject("ADSystemInfo")
  12. Set oPath = CreateObject("Path")    'Create a Path Object
  13. Set oUser = GetObject("LDAP://" & sysInfo.UserName & "")
  14.  
  15. strUserName = sysInfo.UserName
  16.  
  17. Debug.Print "User Name: " & strUserName
  18. Debug.Print "User Phone#: " & oUser.TelephoneNumber
  19. Debug.Print "User E-Mail Address: " & oUser.EmailAddress
  20.  
  21. Debug.Print "Computer Name: " & sysInfo.ComputerName
  22. Debug.Print "Site Name: " & sysInfo.SiteName
  23. Debug.Print "Domain DNS Name: " & sysInfo.DomainDNSName
  24.  
  25. 'Retrieve Properties of the Path Object
  26. Debug.Print "Path: " & oPath.Path
  27. Debug.Print "Type: " & oPath.Type
  28. Debug.Print "Volume Name: " & oPath.VolumeName
  29.  
  30. Set sysInfo = Nothing
  31. Set oUser = Nothing

4 8785
ADezii
8,834 Expert 8TB
Just subscribing for now. I have some sample Code that I can show you but unfortunately I am at work right now. As soon as I get a chance, I'll post the relevant information.
Mar 10 '13 #2
zmbd
5,501 Expert Mod 4TB
Insights Article #122
Scroll to the bottom of this page, click on the VBA Insights Sitmap link, find the above...
Mar 10 '13 #3
ADezii
8,834 Expert 8TB
The following Code will illustrate the basic concepts on how to extract Information from Active Directory. I cal also supply additional AD Variables if you so desire.
Expand|Select|Wrap|Line Numbers
  1. 'First, you must set a Reference to the Active DS Type Library
  2. Dim sysInfo As Object
  3. Dim oUser As Object
  4. Dim oPath As Object         'Path Class in the ActiveDs Library
  5. Dim intUser As Integer
  6. Dim strLName As String
  7. Dim strFName As String
  8. Dim strUserName As String
  9. 'Dim strEMail As String
  10.  
  11. Set sysInfo = CreateObject("ADSystemInfo")
  12. Set oPath = CreateObject("Path")    'Create a Path Object
  13. Set oUser = GetObject("LDAP://" & sysInfo.UserName & "")
  14.  
  15. strUserName = sysInfo.UserName
  16.  
  17. Debug.Print "User Name: " & strUserName
  18. Debug.Print "User Phone#: " & oUser.TelephoneNumber
  19. Debug.Print "User E-Mail Address: " & oUser.EmailAddress
  20.  
  21. Debug.Print "Computer Name: " & sysInfo.ComputerName
  22. Debug.Print "Site Name: " & sysInfo.SiteName
  23. Debug.Print "Domain DNS Name: " & sysInfo.DomainDNSName
  24.  
  25. 'Retrieve Properties of the Path Object
  26. Debug.Print "Path: " & oPath.Path
  27. Debug.Print "Type: " & oPath.Type
  28. Debug.Print "Volume Name: " & oPath.VolumeName
  29.  
  30. Set sysInfo = Nothing
  31. Set oUser = Nothing
Mar 10 '13 #4
anoble1
245 128KB
So, the only information I will need to grab this info is my Company Domain? What is the siteName reffering to?
Mar 10 '13 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Tom Petersen | last post by:
Hello, we just migrated to Windows Server 2003 and active directory. On our intranet I would like to personalize some of the pages my users hit. Let's say I login as petertom, when I go to my...
6
by: Leo_Surf | last post by:
Hello, I need your help adding user in Active Directory from ASP.net website. Could any one provide me the complete code for the html page. As this is my curriculam project and I dont have any...
2
by: Alpha | last post by:
I need to retrieve and set information in Active Directory in a new project that I'll be working on. I went to Amazon.com to look for a good book on this subject but found books on this subject...
2
by: Jim in Arizona | last post by:
My goal, somehow, is to populate a dropdownlist with all the user names in active directory. I don't even know where to begin, really. I added a reference to System.DirectoryServices so I could...
0
by: Chung Leong | last post by:
In this brief tutorial I'll describe how you retrieve information from an Active Directory through the OLE-DB extension. While it is possible to use the LDAP extension to achieve the same goal, as...
3
by: =?Utf-8?B?QlVCQkxFVEFMSzI2MA==?= | last post by:
Hello. I am writing an application that uses Active Directory and needs to grab user information. I pass user email addresses and and get back a userInfo structure with AD information. My issue is...
7
by: Vio | last post by:
Hello everyone, i currently a beginner in php. I want to ask about Win2003 Active Directory users. Is it possible to retrieve Win2003 AD (just username & password) with php. I'm currenty...
3
by: yawnmoth | last post by:
I'm trying to connect to an Active Directory server and am having some difficulties. Here's the code I'm using: <?php if (!($ldap = ldap_connect('domain.tld')) { exit('unable to connect'); }...
0
by: Zetten | last post by:
I'm trying to develop a page which will grab a few details for the currently logged-in Windows user from the Active Directory controller. I can get the full name of the user from their username...
0
by: davincith | last post by:
My System Have 2 Computer: Frist Computer act as A domain Controller that has a Active Directory,RADIUS Server,DHCP and DNS Second Computer act as A Web Server(join domain with a first computer...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.