Exemplo n.º 1
0
        public static SafeFreeCredentials AcquireCredentialsHandle(SSPIInterface secModule, string package, Interop.SspiCli.CredentialUse intent, ref Interop.SspiCli.SEC_WINNT_AUTH_IDENTITY_W authdata)
        {
            if (GlobalLog.IsEnabled)
            {
                GlobalLog.Print("SSPIWrapper::AcquireCredentialsHandle#2(): using " + package);
            }

            if (SecurityEventSource.Log.IsEnabled())
            {
                SecurityEventSource.AcquireCredentialsHandle(package, intent, authdata);
            }

            SafeFreeCredentials credentialsHandle = null;
            int errorCode = secModule.AcquireCredentialsHandle(package,
                                                               intent,
                                                               ref authdata,
                                                               out credentialsHandle);

            if (errorCode != 0)
            {
#if TRACE_VERBOSE
                if (GlobalLog.IsEnabled)
                {
                    GlobalLog.Print("SSPIWrapper::AcquireCredentialsHandle#2(): error " + Interop.MapSecurityStatus((uint)errorCode));
                }
#endif
                if (NetEventSource.Log.IsEnabled())
                {
                    NetEventSource.PrintError(NetEventSource.ComponentType.Security, SR.Format(SR.net_log_operation_failed_with_error, "AcquireCredentialsHandle()", String.Format(CultureInfo.CurrentCulture, "0X{0:X}", errorCode)));
                }

                throw new Win32Exception(errorCode);
            }
            return(credentialsHandle);
        }
Exemplo n.º 2
0
        public static SafeFreeCredentials AcquireCredentialsHandle(SSPIInterface secModule, string package, Interop.SspiCli.CredentialUse intent, Interop.SspiCli.SCHANNEL_CRED scc)
        {
            if (NetEventSource.IsEnabled)
            {
                NetEventSource.Enter(null, package);
                NetEventSource.Log.AcquireCredentialsHandle(package, intent, scc);
            }

            SafeFreeCredentials outCredential = null;
            int errorCode = secModule.AcquireCredentialsHandle(
                package,
                intent,
                ref scc,
                out outCredential);

            if (errorCode != 0)
            {
                if (NetEventSource.IsEnabled)
                {
                    NetEventSource.Error(null, System.StringsHelper.Format(Strings.net_log_operation_failed_with_error, nameof(AcquireCredentialsHandle), $"0x{errorCode:X}"));
                }
                throw new Win32Exception(errorCode);
            }

            if (NetEventSource.IsEnabled)
            {
                NetEventSource.Exit(null, outCredential);
            }
            return(outCredential);
        }
Exemplo n.º 3
0
        AcquireCredentialsHandle(SSPIInterface SecModule,
                                 string package,
                                 CredentialUse intent,
                                 AuthIdentity authdata
                                 )
        {
            GlobalLog.Print("SSPIWrapper::AcquireCredentialsHandle#2(): using " + package);

            CredentialsHandle credentialsHandle = new CredentialsHandle(SecModule);
            int errorCode = SecModule.AcquireCredentialsHandle(null,
                                                               package,
                                                               (int)intent,
                                                               0,
                                                               authdata,
                                                               0,
                                                               0,
                                                               ref credentialsHandle.Handle,
                                                               ref credentialsHandle.TimeStamp
                                                               );

            if (errorCode != 0)
            {
#if TRAVE
                GlobalLog.Print("SSPIWrapper::AcquireCredentialsHandle#2(): error " + SecureChannel.MapSecurityStatus((uint)errorCode));
#endif
                throw new Win32Exception(errorCode);
            }
            return(credentialsHandle);
        }
Exemplo n.º 4
0
        public static SafeFreeCredentials AcquireCredentialsHandle(SSPIInterface secModule, string package, Interop.SspiCli.CredentialUse intent, ref Interop.SspiCli.SEC_WINNT_AUTH_IDENTITY_W authdata)
        {
            if (NetEventSource.IsEnabled)
            {
                NetEventSource.Enter(null, package);
                NetEventSource.Log.AcquireCredentialsHandle(package, intent, authdata);
            }

            SafeFreeCredentials credentialsHandle = null;
            int errorCode = secModule.AcquireCredentialsHandle(package,
                                                               intent,
                                                               ref authdata,
                                                               out credentialsHandle);

            if (errorCode != 0)
            {
                if (NetEventSource.IsEnabled)
                {
                    NetEventSource.Error(null, SR.Format(SR.net_log_operation_failed_with_error, nameof(AcquireCredentialsHandle), $"0x{errorCode:X}"));
                }

                throw new Win32Exception(errorCode);
            }
            return(credentialsHandle);
        }
        public static SafeFreeCredentials AcquireCredentialsHandle(SSPIInterface SecModule, string package, CredentialUse intent, ref AuthIdentity authdata)
        {
            GlobalLog.Print("SSPIWrapper::AcquireCredentialsHandle#2(): using " + package);

            if (Logging.On)
            {
                Logging.PrintInfo(Logging.Web,
                                  "AcquireCredentialsHandle(" +
                                  "package  = " + package + ", " +
                                  "intent   = " + intent + ", " +
                                  "authdata = " + authdata + ")");
            }

            SafeFreeCredentials credentialsHandle = null;
            int errorCode = SecModule.AcquireCredentialsHandle(package,
                                                               intent,
                                                               ref authdata,
                                                               out credentialsHandle
                                                               );

            if (errorCode != 0)
            {
#if TRAVE
                GlobalLog.Print("SSPIWrapper::AcquireCredentialsHandle#2(): error " + SecureChannel.MapSecurityStatus((uint)errorCode));
#endif
                if (Logging.On)
                {
                    Logging.PrintError(Logging.Web, SR.GetString(SR.net_log_operation_failed_with_error, "AcquireCredentialsHandle()", String.Format(CultureInfo.CurrentCulture, "0X{0:X}", errorCode)));
                }
                throw new Win32Exception(errorCode);
            }
            return(credentialsHandle);
        }
Exemplo n.º 6
0
        AcquireCredentialsHandle(SSPIInterface SecModule,
                                 string package,
                                 CredentialUse intent,
                                 SChannelCred scc
                                 )
        {
            GlobalLog.Print("SSPIWrapper::AcquireCredentialsHandle#3(): using " + package);

            CredentialsHandle credentialsHandle      = new CredentialsHandle(SecModule);
            GCHandle          pinnedCertificateArray = new GCHandle();

            if (scc.certContextArray != IntPtr.Zero)
            {
                //
                // We hide the fact that this array must be marshalled
                //  and Pinned, we convert the single value into a pined array
                //  for the Unmanaged call
                //

                IntPtr [] certContextArray = new IntPtr[1] {
                    scc.certContextArray
                };

                pinnedCertificateArray = GCHandle.Alloc(certContextArray, GCHandleType.Pinned);

                //
                // Its now pinned, so get a ptr to its base
                //  this is needed because the Common Language Runtime doesn't support this natively
                //

                scc.certContextArray = pinnedCertificateArray.AddrOfPinnedObject();
            }

            int errorCode = SecModule.AcquireCredentialsHandle(
                null,
                package,
                (int)intent,
                0,
                ref scc,
                0,
                0,
                ref credentialsHandle.Handle,
                ref credentialsHandle.TimeStamp
                );

            if (pinnedCertificateArray.IsAllocated)
            {
                pinnedCertificateArray.Free();
            }

            if (errorCode != 0)
            {
#if TRAVE
                GlobalLog.Print("SSPIWrapper::AcquireCredentialsHandle#3(): error " + SecureChannel.MapSecurityStatus((uint)errorCode));
#endif
                throw new Win32Exception(errorCode);
            }
            GlobalLog.Print("SSPIWrapper::AcquireCredentialsHandle#3(): cred handle = 0x" + String.Format("{0:x}", credentialsHandle.Handle));
            return(credentialsHandle);
        }
Exemplo n.º 7
0
        public static SafeFreeCredentials AcquireCredentialsHandle(SSPIInterface secModule, string package, Interop.Secur32.CredentialUse intent, ref SafeSspiAuthDataHandle authdata)
        {
            if (Logging.On)
            {
                Logging.PrintInfo(Logging.Web,
                                  "AcquireCredentialsHandle(" +
                                  "package  = " + package + ", " +
                                  "intent   = " + intent + ", " +
                                  "authdata = " + authdata + ")");
            }

            SafeFreeCredentials credentialsHandle = null;
            int errorCode = secModule.AcquireCredentialsHandle(package, intent, ref authdata, out credentialsHandle);

            if (errorCode != 0)
            {
                if (Logging.On)
                {
                    Logging.PrintError(Logging.Web, SR.Format(SR.net_log_operation_failed_with_error, "AcquireCredentialsHandle()", String.Format(CultureInfo.CurrentCulture, "0X{0:X}", errorCode)));
                }

                throw new Win32Exception(errorCode);
            }

            return(credentialsHandle);
        }
Exemplo n.º 8
0
        public static SafeFreeCredentials AcquireCredentialsHandle(SSPIInterface secModule, string package, Interop.SspiCli.CredentialUse intent, Interop.SspiCli.SecureCredential scc)
        {
            GlobalLog.Print("SSPIWrapper::AcquireCredentialsHandle#3(): using " + package);

            if (SecurityEventSource.Log.IsEnabled())
            {
                SecurityEventSource.AcquireCredentialsHandle(package, intent, scc);
            }

            SafeFreeCredentials outCredential = null;
            int errorCode = secModule.AcquireCredentialsHandle(
                package,
                intent,
                ref scc,
                out outCredential);

            if (errorCode != 0)
            {
#if TRACE_VERBOSE
                GlobalLog.Print("SSPIWrapper::AcquireCredentialsHandle#3(): error " + Interop.MapSecurityStatus((uint)errorCode));
#endif

                if (NetEventSource.Log.IsEnabled())
                {
                    NetEventSource.PrintError(NetEventSource.ComponentType.Security, SR.Format(SR.net_log_operation_failed_with_error, "AcquireCredentialsHandle()", String.Format(CultureInfo.CurrentCulture, "0X{0:X}", errorCode)));
                }

                throw new Win32Exception(errorCode);
            }

#if TRACE_VERBOSE
            GlobalLog.Print("SSPIWrapper::AcquireCredentialsHandle#3(): cred handle = " + outCredential.ToString());
#endif
            return(outCredential);
        }
Exemplo n.º 9
0
        internal static SafeFreeCredentials AcquireCredentialsHandle(SSPIInterface SecModule, X509Certificate certificate, SslProtocols protocols, EncryptionPolicy policy, bool isServer)
        {
            if (Logging.On)
            {
                Logging.PrintInfo(Logging.Web,
                                  "AcquireCredentialsHandle(" +
                                  "protocols  = " + protocols + ", " +
                                  "policy   = " + policy + ", " +
                                  "isServer = " + isServer + ")");
            }

            return(SecModule.AcquireCredentialsHandle(certificate, protocols, policy, isServer));
        }
 public static SafeFreeCredentials AcquireCredentialsHandle(SSPIInterface SecModule, string package, CredentialUse intent, SecureCredential scc)
 {
     if (Logging.On)
     {
         Logging.PrintInfo(Logging.Web, string.Concat(new object[] { "AcquireCredentialsHandle(package = ", package, ", intent  = ", intent, ", scc     = ", scc, ")" }));
     }
     SafeFreeCredentials outCredential = null;
     int error = SecModule.AcquireCredentialsHandle(package, intent, ref scc, out outCredential);
     if (error == 0)
     {
         return outCredential;
     }
     if (Logging.On)
     {
         Logging.PrintError(Logging.Web, SR.GetString("net_log_operation_failed_with_error", new object[] { "AcquireCredentialsHandle()", string.Format(CultureInfo.CurrentCulture, "0X{0:X}", new object[] { error }) }));
     }
     throw new Win32Exception(error);
 }
        public static SafeFreeCredentials AcquireCredentialsHandle(SSPIInterface SecModule, string package, CredentialUse intent, SecureCredential scc)
        {
            if (Logging.On)
            {
                Logging.PrintInfo(Logging.Web, string.Concat(new object[] { "AcquireCredentialsHandle(package = ", package, ", intent  = ", intent, ", scc     = ", scc, ")" }));
            }
            SafeFreeCredentials outCredential = null;
            int error = SecModule.AcquireCredentialsHandle(package, intent, ref scc, out outCredential);

            if (error == 0)
            {
                return(outCredential);
            }
            if (Logging.On)
            {
                Logging.PrintError(Logging.Web, SR.GetString("net_log_operation_failed_with_error", new object[] { "AcquireCredentialsHandle()", string.Format(CultureInfo.CurrentCulture, "0X{0:X}", new object[] { error }) }));
            }
            throw new Win32Exception(error);
        }
Exemplo n.º 12
0
        public static SafeFreeCredentials AcquireCredentialsHandle(SSPIInterface secModule, string package, Interop.Secur32.CredentialUse intent, Interop.Secur32.SecureCredential scc)
        {
            GlobalLog.Print("SSPIWrapper::AcquireCredentialsHandle#3(): using " + package);

            if (Logging.On)
            {
                Logging.PrintInfo(Logging.Web,
                                  "AcquireCredentialsHandle(" +
                                  "package = " + package + ", " +
                                  "intent  = " + intent + ", " +
                                  "scc     = " + scc + ")");
            }

            SafeFreeCredentials outCredential = null;
            int errorCode = secModule.AcquireCredentialsHandle(
                package,
                intent,
                ref scc,
                out outCredential
                );

            if (errorCode != 0)
            {
#if TRACE_VERBOSE
                GlobalLog.Print("SSPIWrapper::AcquireCredentialsHandle#3(): error " + Interop.MapSecurityStatus((uint)errorCode));
#endif

                if (Logging.On)
                {
                    Logging.PrintError(Logging.Web, SR.Format(SR.net_log_operation_failed_with_error, "AcquireCredentialsHandle()", String.Format(CultureInfo.CurrentCulture, "0X{0:X}", errorCode)));
                }

                throw new Win32Exception(errorCode);
            }

#if TRACE_VERBOSE
            GlobalLog.Print("SSPIWrapper::AcquireCredentialsHandle#3(): cred handle = " + outCredential.ToString());
#endif
            return(outCredential);
        }
Exemplo n.º 13
0
        public static SafeFreeCredentials AcquireCredentialsHandle(SSPIInterface secModule, string package, Interop.SspiCli.CredentialUse intent, ref SafeSspiAuthDataHandle authdata)
        {
            if (SecurityEventSource.Log.IsEnabled())
            {
                SecurityEventSource.AcquireCredentialsHandle(package, intent, authdata);
            }

            SafeFreeCredentials credentialsHandle = null;
            int errorCode = secModule.AcquireCredentialsHandle(package, intent, ref authdata, out credentialsHandle);

            if (errorCode != 0)
            {
                if (NetEventSource.Log.IsEnabled())
                {
                    NetEventSource.PrintError(NetEventSource.ComponentType.Security, SR.Format(SR.net_log_operation_failed_with_error, "AcquireCredentialsHandle()", String.Format(CultureInfo.CurrentCulture, "0X{0:X}", errorCode)));
                }

                throw new Win32Exception(errorCode);
            }

            return(credentialsHandle);
        }