Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading Active Directory for user names

Status
Not open for further replies.

Bruce1965

Programmer
Sep 17, 2004
54
GB
I am writing a .net application that, as part of the process, will read the Active Directory and return all domain usernames into a combobox.

Question: Can someone give me some sample code to do this (or indeed point me to somewhere that can)?????

[ponder]
 
This is a function I use to get a user's full name from Active Directory, it may give you an idea of where to start looking.

Code:
    Public Shared Function UserNameLong(ByVal UserID As String)
      Dim FullName As String
      Try
        Dim ADEntry As New System.DirectoryServices.DirectoryEntry("WinNT://DomainName/" & UserID.Trim)
        FullName = ADEntry.Properties("FullName").Value
      Catch exc As Exception
        FullName = ""
      End Try
      Return FullName
    End Function

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Thanks, Rick

I got it working, although I didn't use your code line for line. However, the line

Code:
FullName = ADEntry.Properties("FullName").Value

was spot on.

Cheers mate
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top