SqlContext::WindowsIdentity Property
The Microsoft Windows identity of the caller.
Assembly: System.Data (in System.Data.dll)
Property Value
Type: System.Security.Principal::WindowsIdentityA WindowsIdentity instance representing the Windows identity of the caller, or nullptr if the client was authenticated using SQL Server Authentication.
Common language runtime (CLR) code inside SQL Server is always invoked in the context of the process account. If it is necessary for the code to perform an action using calling user’s identity instead of the SQL Server process identity, then an impersonation token should be obtained through this property. After obtaining the WindowsIdentity object, callers can impersonate the client account and perform actions on their behalf.
If invoked from outside SQL Server, a NotSupportedException is thrown.
Only assemblies marked with EXTERNAL_ACCESS or UNSAFE permissions can access this property.
This property is read-only.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.