Retrieve User Name in C#.net

Discussion in 'ASP .Net Security' started by Guest, Mar 15, 2005.

  1. Guest

    Guest Guest

    Hi All,

    I am trying to find how to retrieve the user name
    using .Net. I know how to retrieve the user login using
    HttpContext.Current.User.Identity.Name but I ned to
    retrieve the name and not the login.

    Thanks In Advance.
    Guest, Mar 15, 2005
    #1
    1. Advertising

  2. Guest

    Brock Allen Guest

    There's no API in ASP.NET to do this for you. You'll have to take the login
    you have and query whatever the authentication source is to determine that
    info.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen

    > Hi All,
    >
    > I am trying to find how to retrieve the user name using .Net. I know
    > how to retrieve the user login using
    > HttpContext.Current.User.Identity.Name but I ned to retrieve the name
    > and not the login.
    >
    > Thanks In Advance.
    >
    Brock Allen, Mar 15, 2005
    #2
    1. Advertising

  3. Guest

    Paul Clement Guest

    On Tue, 15 Mar 2005 14:43:07 -0800, <> wrote:

    ¤ Hi All,
    ¤
    ¤ I am trying to find how to retrieve the user name
    ¤ using .Net. I know how to retrieve the user login using
    ¤ HttpContext.Current.User.Identity.Name but I ned to
    ¤ retrieve the name and not the login.

    I don't have a C# example but the below should be easy to convert. The System.DirectoryServices
    namespace is required:

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

    Dim FullName As String = ADEntry.Properties("FullName").Value


    Paul
    ~~~~
    Microsoft MVP (Visual Basic)
    Paul Clement, Mar 16, 2005
    #3
  4. Guest

    Jean Guest

    I used the same thing but insted of user name I get "ASP.NET Machine Account
    " Does any one knows Why??????
    Jean, Jan 13, 2006
    #4
  5. Guest

    Winista Guest

    Have you turned on impesonation?

    "Jean" <> wrote in message
    news:...
    >I used the same thing but insted of user name I get "ASP.NET Machine
    >Account
    > " Does any one knows Why??????
    Winista, Jan 13, 2006
    #5
  6. Also use :- User.Identity.Name
    Patrick

    "Winista" <> wrote in message
    news:u$...
    > Have you turned on impesonation?
    >
    > "Jean" <> wrote in message
    > news:...
    > >I used the same thing but insted of user name I get "ASP.NET Machine
    > >Account
    > > " Does any one knows Why??????

    >
    >
    Patrick.O.Ige, Jan 25, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. venkat

    Retrieve logon user name from ADSI

    venkat, Nov 6, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    457
    venkat
    Nov 6, 2003
  2. nalbayo
    Replies:
    2
    Views:
    5,491
    Bruce Barker
    Nov 11, 2005
  3. Antonio O''Neal

    user.identity.name returns old AD user name

    Antonio O''Neal, Oct 31, 2008, in forum: ASP .Net Security
    Replies:
    5
    Views:
    2,058
    Antonio O''Neal
    Nov 3, 2008
  4. User Groups

    Retrieve user login name

    User Groups, Aug 17, 2008, in forum: ASP General
    Replies:
    3
    Views:
    115
    User Groups
    Aug 17, 2008
  5. Replies:
    6
    Views:
    161
Loading...

Share This Page