SSPI context
Inheritance: IDisposable
コード例 #1
0
        /// <summary>
        /// Create SSPI context for client
        /// </summary>
        public static SSPIContext CreateClient()
        {
            // Create an instance of the context
            SSPIContext context = new SSPIContext();

            // Initialize token lifetime container
            SecurityInteger lifeTime = new SecurityInteger();

            // Delegate into security API
            int secReturnCode = SecurityWrapper.AcquireCredentialsHandle(null, SecConstants.Negotiate, (int)SecPgkCredentials.Outbound, IntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero, ref context._outboundCredential, ref lifeTime);

            // Check if we succeeded
            if (secReturnCode != (int)SecResult.Ok)
            {
                // We couldn't obtain server credentials handle
                throw new Win32Exception(secReturnCode, "Failed to acquire client credentials handle");
            }

            return(context);
        }
コード例 #2
0
ファイル: SSPIContext.Windows.cs プロジェクト: dotnet/corefx
        /// <summary>
        /// Create SSPI context for client
        /// </summary>
        public static SSPIContext CreateClient()
        {
            // Create an instance of the context
            SSPIContext context = new SSPIContext();

            // Initialize token lifetime container
            SecurityInteger lifeTime = new SecurityInteger();

            // Delegate into security API
            int secReturnCode = SecurityWrapper.AcquireCredentialsHandle(null, SecConstants.Negotiate, (int)SecPgkCredentials.Outbound, IntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero, ref context._outboundCredential, ref lifeTime);

            // Check if we succeeded
            if (secReturnCode != (int)SecResult.Ok)
            {
                // We couldn't obtain server credentials handle
                throw new Win32Exception(secReturnCode, "Failed to acquire client credentials handle");
            }

            return context;
        }