Currently I am storing windows account of a user as nvarchar(10) in sql server, is this the correct way to store userids? What should be the data type? or should I even store userids?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Windows NT user identities are known as SID, a security-identifier. It’s string representation is specified in SID String Format Syntax and the marshal representation is specified in SID–Packet Representation. If you want to store a SID in the database, use the same representation as the
sys.databases.owner_sidfield: varbinary(85). To retrieve a login SID useSUSER_SID(which also returns…varbinary(85)).Specifically do not store identities as login names (
domain\useroruser@domain) since these change way more frequently than you expect, specially in large corporations. Mine changed about 5 times in 10 years.