public bool TryAcquireServerChallenge(WindowsAuthenticationToken message) { bool result = false; SecurityBufferDesciption clientToken = new SecurityBufferDesciption(message.Data); SecurityBufferDesciption serverToken = new SecurityBufferDesciption(MaximumTokenSize); try { SecurityInteger lifetime = new SecurityInteger(0); uint contextAttributes; if (NativeMethods.AcquireCredentialsHandle(null, "NTLM", SecurityCredentialsInbound, IntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero, ref credentials, ref lifetime) == 0) { if (NativeMethods.AcceptSecurityContext(ref credentials, IntPtr.Zero, ref clientToken, StandardContextAttributes, SecurityNativeDataRepresentation, out context, out serverToken, out contextAttributes, out lifetime) == IntermediateResult) { result = true; } } } finally { message.Data = serverToken.GetBytes(); clientToken.Dispose(); serverToken.Dispose(); } return result; }