why is 'HttpContext.Current.User.Identity as WindowsIdentity' coming back as null or returning the name of app service?? RRS feed

  • Question

  • Hi,

    I am making a HTTPS get request from android application with an access token from Azure Active Directory. I want to use this token to access the a SQL database for the specific logged in user for row level security. I am trying to use Windows Identity to impersonate the user but I am either getting null or the name of the app service not the specific user who has logged in. 

    This returns null:var winIdent = HttpContext.Current.User.Identity as WindowsIdentity;

    This returns name of app service everytime: 

    IntPtr accountToken = WindowsIdentity.GetCurrent().Token;
                WindowsIdentity winIdent = new WindowsIdentity(accountToken);

    How do I get the details of the specific user who is logged in??! Any help would be amazing.



    Wednesday, July 17, 2019 9:02 AM

All replies

  • Hi Gareth Sanashee, 

    Thank you for posting here.

    According to your description, your issue is more related to android. Therefore, it will be more appropriate to ask your question in android Forums.

    The CLR Forum discuss and ask questions about .NET Framework Base Classes (BCL) such as Collections, I/O, Regigistry, Globalization, Reflection. Also discuss all the other Microsoft libraries that are built on or extend the .NET Framework, including Managed Extensibility Framework (MEF), Charting Controls, CardSpace, Windows Identity Foundation (WIF), Point of Sale (POS), Transactions.

    Thank you for your understanding.

    Best Regards,

    Xingyu Zhao

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, July 18, 2019 8:59 AM