Results 1 to 10 of 10

Thread: [VB2005] Getting Windows account name using Windows Authentication

  1. #1

    Thread Starter
    Addicted Member mday2792's Avatar
    Join Date
    Dec 2006
    Posts
    145

    [VB2005] Getting Windows account name using Windows Authentication

    Anyone know how to get the name on the windows account using windows auth such as "Joe Smith"?

  2. #2
    Fanatic Member space_monkey's Avatar
    Join Date
    Apr 2005
    Location
    神と歩くこと
    Posts
    573

    Re: [VB2005] Getting Windows account name using Windows Authentication

    Try Request.LogonUserIdentity.Name
    Using VB6 or VB.net 2008 with .net 3.5
    "Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad

  3. #3

    Thread Starter
    Addicted Member mday2792's Avatar
    Join Date
    Dec 2006
    Posts
    145

    Re: [VB2005] Getting Windows account name using Windows Authentication

    Thank you but no luck. It gives me "DOMAIN\username".

    I would imagine if Windows can authenticate you then you should be able to obtain other account attributes.

    Anyone have any suggestions?

  4. #4
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    Re: [VB2005] Getting Windows account name using Windows Authentication

    Yes, if you query Active Directory directly: http://www.vbforums.com/showthread.p...tive+directory

  5. #5

    Thread Starter
    Addicted Member mday2792's Avatar
    Join Date
    Dec 2006
    Posts
    145

    Re: [VB2005] Getting Windows account name using Windows Authentication

    How can I query the active directory without specifing a password? I am using Windows Authentication therefore the user is not typing in their logon info.

  6. #6
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    Re: [VB2005] Getting Windows account name using Windows Authentication

    Change the query to search for the authenticated user, e.g. "(&(objecttype=person)(sAMAccountName=foo)", then use a "system" account to execute the query.

  7. #7

    Thread Starter
    Addicted Member mday2792's Avatar
    Join Date
    Dec 2006
    Posts
    145

    Re: [VB2005] Getting Windows account name using Windows Authentication

    Can you provide a more detailed example? I am not following. Thanks.

  8. #8

    Thread Starter
    Addicted Member mday2792's Avatar
    Join Date
    Dec 2006
    Posts
    145

    Re: [VB2005] Getting Windows account name using Windows Authentication

    I understand the search query, but what do you mean by a "system account to execute"?

    Can you provide an example?

  9. #9
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: [VB2005] Getting Windows account name using Windows Authentication

    Make sure that Anonymous User are not allowed. In the Web Config, set
    VB Code:
    1. <authorization>
    2.   <deny users="?"/> ' "?" means anonymous user
    3. </authorization>
    Also check in IIS that Integrated Windows Authentication box is checked.

    and in your code behind:
    VB Code:
    1. System.Security.Principal.IPrincipal user;
    2. user = System.Web.HttpContext.Current.User;
    3. string name = user.Identity.Name;
    4. 'Display name
    Show Appreciation. Rate Posts.

  10. #10

    Thread Starter
    Addicted Member mday2792's Avatar
    Join Date
    Dec 2006
    Posts
    145

    Re: [VB2005] Getting Windows account name using Windows Authentication

    Thanks but it gives me the 'username'. I need the account name or common name such as 'John Doe'.

    Does anyone know how to obtain this without using LDAP?

Posting Permissions

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



Click Here to Expand Forum to Full Width