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

LDAP or active directory?

In my current asp.net application i'm getting the user network short name
and displaying that on the screen. What I want is the users Full name and
display that instear. How can i go about doing that, would I use LDAP or
Active directory to do that?

I never had to do this and not sure how to do it or where to start looking.

Ex: this is what i get now.
jsmith - network logon ID

what I want is:
John Smith.

is this possible?
thx
Nov 20 '05 #1
3 1352
This function do exactly what you need :0)

I'm using this function with WinForms, but I think that's will work in
Asp.Net too.

Public Shared Function GetFullName(ByVal DomainName As String, ByVal
UserName As String) As String
Dim oDirectory As New DirectoryEntry("LDAP://" & DomainName)
Dim mySearcher As New DirectorySearcher(oDirectory)
Dim oResult As SearchResult
Dim sResult As String
mySearcher.SearchScope = SearchScope.Subtree
mySearcher.ReferralChasing = ReferralChasingOption.All
mySearcher.Filter = "(&(objectClass=user)(sAMAccountName=" & UserName &
"))"

Try
oResult = mySearcher.FindOne
If Not oResult Is Nothing Then
sResult =
oResult.GetDirectoryEntry.Properties("DisplayName" ).Value.ToString
End If
Catch ex As Exception
Throw ex
End Try

oResult = Nothing
mySearcher.Dispose()
oDirectory.Dispose()

Return sResult
End Function
--
Eric

"Mike" <cs*********@sbcglobal.net> wrote in message
news:Or**************@TK2MSFTNGP12.phx.gbl...
In my current asp.net application i'm getting the user network short name
and displaying that on the screen. What I want is the users Full name and
display that instear. How can i go about doing that, would I use LDAP or
Active directory to do that?

I never had to do this and not sure how to do it or where to start looking.
Ex: this is what i get now.
jsmith - network logon ID

what I want is:
John Smith.

is this possible?
thx

Nov 20 '05 #2
are you writing the name anywhere for view?
I need to display the name as well.

"Eric Guillemette" <er***********@jalphaDeleteThis.com> wrote in message
news:#h**************@TK2MSFTNGP12.phx.gbl...
This function do exactly what you need :0)

I'm using this function with WinForms, but I think that's will work in
Asp.Net too.

Public Shared Function GetFullName(ByVal DomainName As String, ByVal
UserName As String) As String
Dim oDirectory As New DirectoryEntry("LDAP://" & DomainName)
Dim mySearcher As New DirectorySearcher(oDirectory)
Dim oResult As SearchResult
Dim sResult As String
mySearcher.SearchScope = SearchScope.Subtree
mySearcher.ReferralChasing = ReferralChasingOption.All
mySearcher.Filter = "(&(objectClass=user)(sAMAccountName=" & UserName & "))"

Try
oResult = mySearcher.FindOne
If Not oResult Is Nothing Then
sResult =
oResult.GetDirectoryEntry.Properties("DisplayName" ).Value.ToString
End If
Catch ex As Exception
Throw ex
End Try

oResult = Nothing
mySearcher.Dispose()
oDirectory.Dispose()

Return sResult
End Function
--
Eric

"Mike" <cs*********@sbcglobal.net> wrote in message
news:Or**************@TK2MSFTNGP12.phx.gbl...
In my current asp.net application i'm getting the user network short name and displaying that on the screen. What I want is the users Full name and display that instear. How can i go about doing that, would I use LDAP or
Active directory to do that?

I never had to do this and not sure how to do it or where to start

looking.

Ex: this is what i get now.
jsmith - network logon ID

what I want is:
John Smith.

is this possible?
thx


Nov 20 '05 #3
You can do anything you want, this function return a string wich contains
the full name of the user.

Exemple:

'My domain name's: MyDomain
'My UserName's: Eric
Dim s As String = GetFullName("MyDomain", "Eric")

The variable 's' will contain "Eric Guillemette" (My full name)

you can put this in a label, combobox, whatever...

--
Eric

"Mike" <cs*********@sbcglobal.net> wrote in message
news:eo*************@TK2MSFTNGP12.phx.gbl...
are you writing the name anywhere for view?
I need to display the name as well.

"Eric Guillemette" <er***********@jalphaDeleteThis.com> wrote in message
news:#h**************@TK2MSFTNGP12.phx.gbl...
This function do exactly what you need :0)

I'm using this function with WinForms, but I think that's will work in
Asp.Net too.

Public Shared Function GetFullName(ByVal DomainName As String, ByVal
UserName As String) As String
Dim oDirectory As New DirectoryEntry("LDAP://" & DomainName)
Dim mySearcher As New DirectorySearcher(oDirectory)
Dim oResult As SearchResult
Dim sResult As String
mySearcher.SearchScope = SearchScope.Subtree
mySearcher.ReferralChasing = ReferralChasingOption.All
mySearcher.Filter = "(&(objectClass=user)(sAMAccountName=" & UserName
&
"))"

Try
oResult = mySearcher.FindOne
If Not oResult Is Nothing Then
sResult =
oResult.GetDirectoryEntry.Properties("DisplayName" ).Value.ToString
End If
Catch ex As Exception
Throw ex
End Try

oResult = Nothing
mySearcher.Dispose()
oDirectory.Dispose()

Return sResult
End Function
--
Eric

"Mike" <cs*********@sbcglobal.net> wrote in message
news:Or**************@TK2MSFTNGP12.phx.gbl...
In my current asp.net application i'm getting the user network short

name and displaying that on the screen. What I want is the users Full name and display that instear. How can i go about doing that, would I use LDAP or Active directory to do that?

I never had to do this and not sure how to do it or where to start

looking.

Ex: this is what i get now.
jsmith - network logon ID

what I want is:
John Smith.

is this possible?
thx



Nov 20 '05 #4

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

Similar topics

2
by: Victor Lokhmatov | last post by:
Hello Everyone, My company has asked me to put a company directory on our intranet site and I'm trying to use php to extract the users from our active directory server. I've got everything...
3
by: Dirk Hagemann | last post by:
Hi! I asked here a few weeks ago the same question but the answer of Tim Golden didn't really help yet. I'd like to know how to set up a query for all computer-accounts in a special part of...
3
by: bwahahahaha | last post by:
Hi, Is there a library in .NET for LDAP? Thanks.
7
by: Amar | last post by:
I am trying to connect to my college LDAP directory using ASP.NET. This LDap does not have security as it returns only user demographic information. i do not need to bind with a username or...
1
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem...
7
by: Sync Walantaji | last post by:
Hi, I would like to write a asp.net winform program to authenticate users on Active Directory. Can I do this with asp.net if the IIS server is not part of the Active directory domain? Is...
4
by: h2so4 | last post by:
I want to write a program that will query an ldap directory. can I use adsi or ado to do that, If yes how ? tx -- h2so4
0
by: RTT | last post by:
here is my current situation. I develop a program on my computer's localhost. From there i contact Active directory succesfull using a connectionstring like:...
1
by: htperth | last post by:
Hi all, Note that I'm new to LDAP and Active Directory and am writing an application that retrieves a simple phone list for all the users in our domain. So far I have the following console app...
1
by: htperth | last post by:
Hi all, Note that I'm new to LDAP and Active Directory and am writing an application that retrieves a simple phone list for all the users in our domain. So far I have the following console app...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.