Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rasmus Beuchert 14 posts 35 karma points
    Jul 21, 2010 @ 12:04
    Rasmus Beuchert
    0

    Getting Active Directory User without logging in

    Hi,

    I am developing an intranet site that needs to get access to the active directory username of the user browsing the site. I don't want people to login, I just want to be able to extract their username.

    I have made this XSLT-extension to get the username, but it just gives me the the user: NT AUTHORITY\NETWORK_SERVICE

            public static string GetLoggedInUser()
    {
    WindowsIdentity currentIdentity = WindowsIdentity.GetCurrent();
    if (currentIdentity != null)
    {
    return String.Format("Authenticated: {0}<br />Username: {1}", currentIdentity.IsAuthenticated, currentIdentity.Name);
    }

    return String.Empty;
    }

    I have tried several attempts configuring the web.config to use <authentication mode="Windows"> and <identity impersonate="true"/> but nothing seems to work.

    Has anyone got an idea of how to acheive my needs?

    Rasmus

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Jul 21, 2010 @ 12:16
  • Rasmus Beuchert 14 posts 35 karma points
    Jul 21, 2010 @ 12:24
    Rasmus Beuchert
    0

    Ismail

    Of course I have searched the forum for answers, and I have read all these threads.

    But my Request.ServerVariables["HTTP_USER"] does not contain anything.

    I have tried disabling anonymous authentication in IIS, but then I get an access denied page.

    I have googled a lot about the configuration of IIS to allow this impersonation, but nothing have worked.

  • Rasmus Beuchert 14 posts 35 karma points
    Jul 21, 2010 @ 14:48
    Rasmus Beuchert
    0

    Well, I finally got something working. It was an IIS module for managing Windows Authentication that wasn't installed :)

  • Simon steed 376 posts 688 karma points
    Mar 08, 2011 @ 15:51
    Simon steed
    0

    Hi,

    I'll be doing something similar shortly - what was the module just in case I get the same issue?

    Si

  • Rasmus Beuchert 14 posts 35 karma points
    Mar 08, 2011 @ 15:56
    Rasmus Beuchert
    0

    Hi,

    The module is just called "Windows Authentication" and must be installed from "Windows Features".

    Control Panel\Programs\Turn Windows Features on or off

    Go to Internet Information Services\World Wide Web Services\Security\Windows Authentication

Please Sign in or register to post replies

Write your reply to:

Draft