473,386 Members | 1,679 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,386 software developers and data experts.

How to get user information from Active Directory?

Does anyone know how to get the user information such as Name, Address, Email, Phone Number, etc from Windows Active Directory? The samples I have seen so far don’t get the User Address, Email, or Phone Number! Thanks.

---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
Jul 21 '05 #1
2 10026
This is an exmple from a previous post. Take a look at the other posts,
there are a lot of questions about system.directoryservices. If you have
more specific questions post them and we can help further.
Jared

Sub GetInfo(ByVal UserName As String) 'User name - NOT display name

Dim Entry As New DirectoryEntry("LDAP://RootDSE")
Dim DomainPath As String = "LDAP://" &
Entry.Properties("defaultNamingContext").Value
Dim Results As SearchResultCollection, Result As SearchResult
'Domain Naming Context
'DC=MyDomain,DC=com
Entry = New DirectoryEntry(DomainPath)
Dim Searcher As New DirectorySearcher(Entry)
With Searcher
.SearchScope = SearchScope.Subtree
.Filter = "(&(objectClass=person)(sAMAccountName=" & UserName &
"))"
'Only works when threaded. Keep this in mind.
'Default size returned is 1000 (server set)
.PageSize = 100
.PropertiesToLoad.AddRange(New String() {"sAMAccountName",
"displayName"})
Result = .FindOne
End With
If Not Result Is Nothing Then
'Watch for multivalued properties
If TypeOf Result.GetDirectoryEntry.Properties("displayName") Is
System.Array Then
MessageBox.Show(Result.GetDirectoryEntry.Propertie s("displayName")(0).Value)
Else
MessageBox.Show(Result.GetDirectoryEntry.Propertie s("displayName").Value)
End If
End If
With Searcher
'You can use wild cards, Look up the RFC on LDAP for more info
.Filter = "(&(objectClass=person)(sAMAccountName=" & UserName &
"*))"
Results = Searcher.FindAll
End With
For Each Result In Results
'Same as before
If TypeOf Result.GetDirectoryEntry.Properties("displayName") Is
System.Array Then
Console.WriteLine(Result.GetDirectoryEntry.Propert ies("displayName")(0).Value)
Else
Console.WriteLine(Result.GetDirectoryEntry.Propert ies("displayName").Value)
End If
Next
End Sub

"DotNetJunkies User" <User@-NOSPAM-DotNetJunkies.com> wrote in message
news:uM**************@tk2msftngp13.phx.gbl...
Does anyone know how to get the user information such as Name, Address,
Email, Phone Number, etc from Windows Active Directory? The samples I have
seen so far donâ?Tt get the User Address, Email, or Phone Number! Thanks.

---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup
engine supports Post Alerts, Ratings, and Searching.

Jul 21 '05 #2
Hi,

One more pointer:
http://www.codeproject.com/csharp/Ge...tDirCSharp.asp

"DotNetJunkies User" <User@-NOSPAM-DotNetJunkies.com> wrote in message
news:uM**************@tk2msftngp13.phx.gbl...
Does anyone know how to get the user information such as Name, Address,
Email, Phone Number, etc from Windows Active Directory? The samples I have
seen so far don’t get the User Address, Email, or Phone Number! Thanks.

---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine
supports Post Alerts, Ratings, and Searching.
Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Federica | last post by:
Hi! I need some help retrieving user information in Active Directory. I have one webform with 2 textboxes 1 username and one for password. When the user load this page and insert his username and...
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...
1
by: Mike Moore | last post by:
Does anyone have suggestions on the best way to check if a user is logged into asp.net web application? We are not using forms authentication. We are authenticating our users against active...
3
by: Buddy Ackerman | last post by:
I have a webservice based app that a company has purchased to use internally. They want the authentication to integrate with their Active Directory. Is there anyway that the client portion of the...
3
by: BlueSky | last post by:
Hi, I have to retrieve user information from active directory in ASP.NET by passing Employee ID to it. Can any one give me some information on how I should do this? Thanks!
18
by: Arthur | last post by:
Hi All, I would like to get the name of the user given their networkID, is this something Active Directory would be useful for?(For intranet users) If so, can you please point me to some sample...
4
by: cpajoe2001 | last post by:
I am not sure if this is the proper place to put this thread but I have run into a road block. I am writing a web app that will create groups in Active Directory then add users to those groups. I...
1
maxamis4
by: maxamis4 | last post by:
Hello folks, Here is the backgroup. I am creating an agent that can find a user in LDAP and return the last logon date. Now i am not sure if with active directory you can user the...
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...
0
by: lairpr74 | last post by:
Hi, I got a console application that updates active directory users, the information to be updated in active directory comes from a database table. This is my problem: right now the application...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.