What Active Directory field do I use to uniquely identify a user?

后端 未结 4 1180
梦谈多话
梦谈多话 2020-12-30 03:05

I have an Asp.net MVC project authenticating through AD. I would like to store audit information in tables for the current logged in user. What should I be storing in the da

4条回答
  •  死守一世寂寞
    2020-12-30 04:02

    If you are using ASP.NET MVC (or Webforms for that matter) with Windows Authentication, why not just use the user name that you get from this property:

    HttpContext.Current.User.Identity.Name
    

    This returns Domain/Username of the user. I have worked on corporate web apps that used this for auditing purposes. I would be curious to know if you think this is not unique enough for your purposes.

    Also I'm not sure why you would want to store a SID or GUID of the user, as it is very hard to read compared to domain/user when you are viewing audit logs.

提交回复
热议问题