none
Can System.Security.Principal.WindowsIdentity.getCurrent().user return null? RRS feed

Answers

  • Hi Davy.R;

    The MSDN page for GetCurrent makes no mention of returning null in any circumstances.

    As that point out, there has to be a current user. so this should always return a valid object - if you have permissions. It can raise a SecurityException.

    For more details, please refer to can WindowsIdentity.GetCurrent() return null?

    Note the reply from nitzanms.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, October 30, 2015 4:41 AM
  • Actually if you look at the source code, you can see since it'll never request thread only token, if the identity it get is null, it'll simply throw SecurityException as Kristin mentioned.

    So yes, you can always assume it'll return some identity if exception is not thrown.

    Friday, October 30, 2015 6:22 AM
    Answerer

All replies

  • Hi Davy.R;

    The MSDN page for GetCurrent makes no mention of returning null in any circumstances.

    As that point out, there has to be a current user. so this should always return a valid object - if you have permissions. It can raise a SecurityException.

    For more details, please refer to can WindowsIdentity.GetCurrent() return null?

    Note the reply from nitzanms.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, October 30, 2015 4:41 AM
  • Actually if you look at the source code, you can see since it'll never request thread only token, if the identity it get is null, it'll simply throw SecurityException as Kristin mentioned.

    So yes, you can always assume it'll return some identity if exception is not thrown.

    Friday, October 30, 2015 6:22 AM
    Answerer
  • Thanks, just confirming.  I need to disposition some Coverity findings regarding dereferencing null return values.
    Friday, October 30, 2015 2:29 PM
  • Thanks, just confirming.  I need to disposition some Coverity findings regarding dereferencing null return values.

    Please remember to close this case by marking helpful reply as an answer.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, November 2, 2015 1:07 AM