/// <summary> /// Impersonates security context on current thread /// </summary> public void ImpersonateContext() { // check object state if (_disposed) { throw new ObjectDisposedException(GetType().FullName); } // impersonate context int error = SSPINative.ImpersonateSecurityContext(ref _contextHandle); if (error < 0) { throw new SSPIException(error, "Could not impersonate security context"); } }