Why do i get i:0#.w|domain\\username and within RunWithElevatedPrivileges domain\apppool?

11,832

The prefix (i:0#.w|) before the username is just an internal code so that SharePoint can identity the type of authentication (w: windows auth, f: formsbased, etc...). The i in the code is to identify that it is a user. FYI if you would try to write out a group, the prefix would be c instead of i.

The fact that you don't have a prefix in elevatedprivileges is that this will always be the admin/pool-account which will always be a windows user - so no need to add the prefix...

Share:
11,832
STORM
Author by

STORM

Allrounder in Microsoft SharePoint, C#, VB.Net, Delphi, Objective-C, Swift. Also interested in Social Software, Next Big Thing etc. "Be water my friend"

Updated on June 25, 2022

Comments

  • STORM
    STORM almost 2 years

    When i do

    Console.WriteLine(SPContext.Current.Web.CurrentUser.LoginName);
    

    i get the following response:

    i:0#.w|domain\\username
    

    When i do

    SPSecurity.RunWithElevatedPrivileges(delegate() {
        Console.WriteLine(SPContext.Current.Web.CurrentUser.LoginName);
    });
    

    i get

    domain\appPoolAccount
    

    without i:0#.w|... within the loginname.

    Is someone able to explain why this happens?

  • STORM
    STORM about 8 years
    But one question: i have tested this this morning under SP 2010 and this does not happen there. Is this SP 2013 specific?
  • Verthosa
    Verthosa about 8 years
    My guess would be that your 2010 machine is only configured for using windows authentication? I am not sure but i want to guide you to this link which has a thorough explanation about the claims prefixes: wictorwilen.se/Post/…
  • FLICKER
    FLICKER over 5 years
    I'm not sure how come this is answers the question!!