Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > Windows Authentication Question !!

Reply
Thread Tools

Windows Authentication Question !!

 
 
naijacoder naijacoder
Guest
Posts: n/a
 
      10-12-2004
Hi Guys,
I have <%=User.Identity.Name%> on my asp.net page and i can
retrieve the Username for example ComputerName/Username or
DomainName/Username.
But my Question is how can i retrieve the full username for
example "John Brown" or the DisplayName.
Any help from you guys!





*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
 
Ken Schaefer
Guest
Posts: n/a
 
      10-12-2004

"naijacoder naijacoder" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Guys,
> I have <%=User.Identity.Name%> on my asp.net page and i can
> retrieve the Username for example ComputerName/Username or
> DomainName/Username.
> But my Question is how can i retrieve the full username for
> example "John Brown" or the DisplayName.
> Any help from you guys!


You have to find out where the "DisplayName" is supposed to be coming from.
When a user authenticates from their web-browser, it only passes the
username and password (or hash/digest of password), not any of the other
properties that might be stored in Active Directory (AD), or in the local
machine's Security Accounts Manager (SAM) Database. If the information is
stored in AD, you would need to use some code to query AD to get the
properties that you want.

Lots of good info:
http://www.google.com.au/search?q=qu...+using+ASP.NET

Cheers
Ken


 
Reply With Quote
 
 
 
 
Paul Clement
Guest
Posts: n/a
 
      10-14-2004
On Tue, 12 Oct 2004 04:20:44 -0700, naijacoder naijacoder <(E-Mail Removed)> wrote:

Hi Guys,
I have <%=User.Identity.Name%> on my asp.net page and i can
retrieve the Username for example ComputerName/Username or
DomainName/Username.
But my Question is how can i retrieve the full username for
example "John Brown" or the DisplayName.
Any help from you guys!


Dim DomainUser As String =
System.Security.Principal.WindowsIdentity.GetCurre nt.Name.Replace("\", "/")
Dim ADEntry As New System.DirectoryServices.DirectoryEntry("WinNT://" & DomainUser)
Dim FullName As String = ADEntry.Properties("FullName").Value


Paul ~~~ http://www.velocityreviews.com/forums/(E-Mail Removed)
Microsoft MVP (Visual Basic)
 
Reply With Quote
 
Chris
Guest
Posts: n/a
 
      10-18-2004
Here ya go.

<%
'get the userName from the form
dim userName as String

userName = Request.Form("userName")

dim con, Com, rs, fullName, description

con = Server.CreateObject("ADODB.Connection")
con.provider = "ADsDSOObject"
con.open("Active Directory Provider")

Com = CreateObject("ADODB.Command")
Com.ActiveConnection = con

Com.CommandText = "SELECT displayName, description, cn FROM
'LDAP://DOMAIN NAME/CN=" & userName & ",OU=GROUP NAME' WHERE
sAMAccountname = '" & userName & "'"
rs = Com.Execute

if not rs.bof and not rs.eof then
fullName = rs("displayName").value
description = rs("cn").value
end if
%>

***** MAKE SURE TO CHANGE THE DOMAIN NAME AND GROUP NAME IN THE LDAP
SELECT STATEMENT. ALSO, YOU WILL NEED TO HAVE AN "OU=" FOR EVERY
GROUP IN YOUR AD HIERARCHY.

Chris



naijacoder naijacoder <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> Hi Guys,
> I have <%=User.Identity.Name%> on my asp.net page and i can
> retrieve the Username for example ComputerName/Username or
> DomainName/Username.
> But my Question is how can i retrieve the full username for
> example "John Brown" or the DisplayName.
> Any help from you guys!
>
>
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

 
Reply With Quote
 
naijacoder naijacoder
Guest
Posts: n/a
 
      10-19-2004
Thx for the code..
But the thing is that i need to display THE USER LOGGED ON(ON TOP OF MY
ASP.PAGE)(BUT THE DISPLAY NAME).
I don't want to display LIST of NAMES!
Any ideas?



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
Joe Kaplan \(MVP - ADSI\)
Guest
Posts: n/a
 
      10-19-2004
You could use System.DirectoryServices fairly easily to search for the user
by their samAccountName and get their displayName from AD.

The samAccountName is the part to the right of the \ in the user name you
get from Context.User.Identity.Name.

There are tons of samples out there that show how to use the
DirectorySearcher.

Joe K.

"naijacoder naijacoder" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thx for the code..
> But the thing is that i need to display THE USER LOGGED ON(ON TOP OF MY
> ASP.PAGE)(BUT THE DISPLAY NAME).
> I don't want to display LIST of NAMES!
> Any ideas?
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



 
Reply With Quote
 
Paul Clement
Guest
Posts: n/a
 
      10-19-2004
On Tue, 19 Oct 2004 04:10:40 -0700, naijacoder naijacoder <(E-Mail Removed)> wrote:

Thx for the code..
But the thing is that i need to display THE USER LOGGED ON(ON TOP OF MY
ASP.PAGE)(BUT THE DISPLAY NAME).
I don't want to display LIST of NAMES!
Any ideas?

I have no idea what you are referring to. The FullName, using the NT provider, is the same as the
displayName using the LDAP provider.


Paul ~~~ (E-Mail Removed)
Microsoft MVP (Visual Basic)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java - Integrated Windows Authentication - NTLM Authentication Forwarding Will Java 5 12-03-2005 01:00 AM
Forms Authentication Ticket Functionality With Windows Authentication jfer ASP .Net Security 3 09-16-2005 06:30 PM
ASP.NET Authentication and Windows Authentication Fabio Gouw ASP .Net Security 2 11-16-2004 01:01 PM
Basic Authentication v. Integrated Windows Authentication w/ Delegation Mark ASP .Net 0 01-20-2004 03:13 PM
Forms authentication with Windows authentication Dadi ASP .Net Security 2 09-16-2003 04:47 AM



Advertisments