Status of authenticated session
        public static bool IsClientResponseValid(byte[] message, ref State state)
        {
            Common.SecurityBufferDesciption ClientToken = new Common.SecurityBufferDesciption(message);
            Common.SecurityBufferDesciption ServerToken = new Common.SecurityBufferDesciption(Common.MaximumTokenSize);

            try
            {
                int result;

                result = AcceptSecurityContext(ref state.Credentials,   // [in] handle to the credentials
                    ref state.Context,                                  // [in/out] handle of partially formed context.  Always NULL the first time through
                    ref ClientToken,                                    // [in] pointer to the input buffers
                    Common.StandardContextAttributes,                   // [in] required context attributes
                    Common.SecurityNativeDataRepresentation,            // [in] data representation on the target
                    out state.Context,                                  // [in/out] receives the new context handle    
                    out ServerToken,                                    // [in/out] pointer to the output buffers
                    out Common.NewContextAttributes,                    // [out] receives the context attributes        
                    out Common.NewLifeTime);                            // [out] receives the life span of the security context

                if (result != Common.SuccessfulResult)
                {
                    return false;
                }
            }
            finally
            {
                ClientToken.Dispose();
                ServerToken.Dispose();
            }

            return true;
        }
        public static bool IsServerChallengeAcquired(ref byte[] message, out State state)
        {
            Common.SecurityBufferDesciption ClientToken = new Common.SecurityBufferDesciption(message);
            Common.SecurityBufferDesciption ServerToken = new Common.SecurityBufferDesciption(Common.MaximumTokenSize);

            try
            {
                int result;

                state = new State();

                result = AcquireCredentialsHandle(WindowsIdentity.GetCurrent().Name,
                    "NTLM",
                    Common.SecurityCredentialsInbound,
                    IntPtr.Zero,
                    IntPtr.Zero,
                    0,
                    IntPtr.Zero,
                    ref state.Credentials,
                    ref Common.NewLifeTime);

                if (result != Common.SuccessfulResult)
                {
                    // Credentials acquire operation failed.
                    return false;
                }

                result = AcceptSecurityContext(ref state.Credentials,   // [in] handle to the credentials
                    IntPtr.Zero,                                        // [in/out] handle of partially formed context.  Always NULL the first time through
                    ref ClientToken,                                    // [in] pointer to the input buffers
                    Common.StandardContextAttributes,                   // [in] required context attributes
                    Common.SecurityNativeDataRepresentation,            // [in] data representation on the target
                    out state.Context,                                  // [in/out] receives the new context handle    
                    out ServerToken,                                    // [in/out] pointer to the output buffers
                    out Common.NewContextAttributes,                    // [out] receives the context attributes        
                    out Common.NewLifeTime);                            // [out] receives the life span of the security context

                if (result != Common.IntermediateResult)
                {
                    // Client challenge issue operation failed.
                    return false;
                }
            }
            finally
            {
                message = ServerToken.GetBytes();

                ClientToken.Dispose();
                ServerToken.Dispose();
            }

            return true;
        }