I am currently storing a Windows user account as nvarchar (10) in sql server, is this the correct way to store user IDs? What should be the data type? or should I even store user IDs?
Windows NT user identifiers are known as SIDs , a security identifier . This string representation is specified in the SID string format syntax , and the marshal's representation is specified in the SID — packet representation . If you want to store the SID in the database, use the same view as the field sys.databases.owner_sid: varbinary (85) . To get the login id, use SUSER_SID(which also returns ... varbinary(85)).
sys.databases.owner_sid
SUSER_SID
varbinary(85)
In particular, do not save identifiers as login names ( domain\useror user@domain), as they change more often than you expect, especially in large corporations. The mine has changed about 5 times in 10 years.
domain\user
user@domain
.
. , , , GUID .
, , , , , , WINDOWS. - , , ? ? , , .
SIMPLE - , , "" , , otoh. , ;)
() char(30).
char(30)
, , 30!
userid, , . userid, nvarchar, , . nvarchar (50)
userid
Stack overflow. Google/Facebook or Yahoo userids, , Passport Authentication. /// ..
Stack overflow
Google/Facebook or Yahoo
Passport Authentication
?
, . . NVarchar(50)
NVarchar(50)