How should I store a Windows userid in a database?

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?

+5
source share
5 answers

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)).

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.

+10
source

.

. , , , GUID .

, , , , , , WINDOWS. - , , ? ? , , .

SIMPLE - , , "" , , otoh. , ;)

+2

() char(30).

, , 30!

+1

userid, , . userid, nvarchar, , . nvarchar (50)

+1

Stack overflow. Google/Facebook or Yahoo userids, , Passport Authentication. /// ..

?

, . . NVarchar(50)

+1

All Articles