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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows Authentication 2

Status
Not open for further replies.

figler

Programmer
Dec 26, 2001
155
US
This should be simple, but (as usual) I am having trouble:

I am successfuly using windows authentication. BUT... I want in my aspx to grab the user name of the authenticated user. I am using system.security.principal.windowsprincipal, but it is giving me the name of the user that the code is running in.

Any help? Thanks! -Brad
 
I use two things...
Here's the first one... It will return the user name with the domain...

page.user.identity.name

(ex: domain/james)

here's a quick funtion I use to drop off the domain name...

public function CurrentUser(ByVal Page as Page) as string
CurrentUser = Right(page.user.identity.name, LeN(page.user.identity) - InStr(1, Page.user.identity.name, "\"))
end function

to call it just use this

= currentuser(page)
it will return just the user name...

--James junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
Never even thought to look in page object... THANKS!!!!!!!!!!!!! -b
 
User.Identity.Name.Split('\\')[1];

returns just the name portion:)

(and User.Identity.Name.Split('\\')[0] gives the domain portion)

fk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top