Retrieve User Name in C#.net

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Retrieve User Name in C#.net

    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

  2. Similar Questions and Discussions

    1. Retrieve URL from DB
      Does anyone know how to pull a URL from a DB? Here's my example: I have a database with training records in it. Inside the DB people fall under...
    2. Cannot retrieve a correct instance from a ListBox in a User Contro
      Hello, I'm trying to develop a simple Web User Control that contains two list boxes, Add and Remove buttons. This User Control transfers the...
    3. retrieve *.jpg
      How can I enter a upc # and retrieve a *.jpg image based on the upc I enter. I have thousands of images, so I cannot use a query and insert a...
    4. after logout, how to retrieve an expired page if user click 'back' button?
      hi everyone, i've made a login and logout page, after user have logout, i want to retrieve an expired page if user click the 'back' button to...
    5. retrieve generated ID
      Hi, I'm using a JDBC T4 driver to connect to a DB2 8.2 database. Is there an easy way to retrieve the value of a generated key, other than...
  3. #2

    Default Re: Retrieve User Name in C#.net

    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
    [url]http://staff.develop.com/ballen[/url]
    > 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 Guest

  4. #3

    Default Re: Retrieve User Name in C#.net

    So - i guess your backend store is AD ?? If yes use the classes found in System.DirectoryService to query for the name - or wait till Joe Kaplan jumps on the thread :)



    ---
    Dominick Baier - DevelopMentor
    [url]http://www.leastprivilege.com[/url]

    nntp://news.microsoft.com/microsoft.public.dotnet.framework.aspnet.security/<7287632465065094985424@msnews.microsoft.com>

    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
    [url]http://staff.develop.com/ballen[/url]
    > 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.
    >


    [microsoft.public.dotnet.framework.aspnet.security]
    Dominick Baier [DevelopMentor] Guest

  5. #4

    Default Re: Retrieve User Name in C#.net

    On Tue, 15 Mar 2005 14:43:07 -0800, <anonymous@discussions.microsoft.com> 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.GetCurre nt.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 Guest

  6. #5

    Default Re: Retrieve User Name in C#.net

    If it is AD as the backend, the System.DirectoryServices and LDAP is a
    possible way to go. You can also potentially p/invoke TranslateName. That
    might be easier.

    It depends a lot on which particular name you want. AD has a lot of them
    (CN, sAMAccountName, NT name, userPrincipalName, displayName,
    distiguishedName, email address, etc.). There are lots of options.

    Joe K.

    "Dominick Baier [DevelopMentor]" <dbaier@pleasepleasenospamdevelop.com>
    wrote in message news:OkLaZ1fKFHA.3392@TK2MSFTNGP10.phx.gbl...
    > So - i guess your backend store is AD ?? If yes use the classes found in
    > System.DirectoryService to query for the name - or wait till Joe Kaplan
    > jumps on the thread :)
    >
    >
    >
    > ---
    > Dominick Baier - DevelopMentor
    > [url]http://www.leastprivilege.com[/url]
    >
    >
    > nntp://news.microsoft.com/microsoft.public.dotnet.framework.aspnet.security/<7287632465065094985424@msnews.microsoft.com>
    >
    > 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
    > [url]http://staff.develop.com/ballen[/url]
    >
    > > 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.
    > >
    >
    >
    >
    > [microsoft.public.dotnet.framework.aspnet.security]

    Joe Kaplan \(MVP - ADSI\) Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139