/// <summary> /// Returns security context access token /// </summary> private WindowsIdentity GetContextIdentity() { // check object state if (_disposed) { throw new ObjectDisposedException(GetType().FullName); } // query context token IntPtr accessToken = IntPtr.Zero; int error = SSPINative.QuerySecurityContextToken( ref _contextHandle, out accessToken); if (error < 0) { throw new SSPIException(error, "Could not determine security context identity"); } return(new WindowsIdentity(accessToken)); }