Example #1
0
        internal static SecurityPackageInfoClass[] EnumerateSecurityPackages(SSPIInterface secModule)
        {
            if (NetEventSource.IsEnabled)
            {
                NetEventSource.Enter(null);
            }

            if (secModule.SecurityPackages == null)
            {
                lock (secModule)
                {
                    if (secModule.SecurityPackages == null)
                    {
                        int moduleCount = 0;
                        SafeFreeContextBuffer arrayBaseHandle = null;
                        try
                        {
                            int errorCode = secModule.EnumerateSecurityPackages(out moduleCount, out arrayBaseHandle);
                            if (NetEventSource.IsEnabled)
                            {
                                NetEventSource.Info(null, $"arrayBase: {arrayBaseHandle}");
                            }
                            if (errorCode != 0)
                            {
                                throw new Win32Exception(errorCode);
                            }

                            var securityPackages = new SecurityPackageInfoClass[moduleCount];

                            int i;
                            for (i = 0; i < moduleCount; i++)
                            {
                                securityPackages[i] = new SecurityPackageInfoClass(arrayBaseHandle, i);
                                if (NetEventSource.IsEnabled)
                                {
                                    NetEventSource.Log.EnumerateSecurityPackages(securityPackages[i].Name);
                                }
                            }

                            secModule.SecurityPackages = securityPackages;
                        }
                        finally
                        {
                            if (arrayBaseHandle != null)
                            {
                                arrayBaseHandle.Dispose();
                            }
                        }
                    }
                }
            }

            if (NetEventSource.IsEnabled)
            {
                NetEventSource.Exit(null);
            }
            return(secModule.SecurityPackages);
        }
Example #2
0
        internal static SecurityPackageInfoClass[] EnumerateSecurityPackages(SSPIInterface secModule)
        {
            if (GlobalLog.IsEnabled)
            {
                GlobalLog.Enter(nameof(EnumerateSecurityPackages));
            }

            if (secModule.SecurityPackages == null)
            {
                lock (secModule)
                {
                    if (secModule.SecurityPackages == null)
                    {
                        int moduleCount = 0;
                        SafeFreeContextBuffer arrayBaseHandle = null;
                        try
                        {
                            int errorCode = secModule.EnumerateSecurityPackages(out moduleCount, out arrayBaseHandle);
                            if (GlobalLog.IsEnabled)
                            {
                                GlobalLog.Print("SSPIWrapper::arrayBase: " + (arrayBaseHandle.DangerousGetHandle().ToString("x")));
                            }
                            if (errorCode != 0)
                            {
                                throw new Win32Exception(errorCode);
                            }

                            var securityPackages = new SecurityPackageInfoClass[moduleCount];

                            int i;
                            for (i = 0; i < moduleCount; i++)
                            {
                                securityPackages[i] = new SecurityPackageInfoClass(arrayBaseHandle, i);
                                if (SecurityEventSource.Log.IsEnabled())
                                {
                                    SecurityEventSource.Log.EnumerateSecurityPackages(securityPackages[i].Name);
                                }
                            }

                            secModule.SecurityPackages = securityPackages;
                        }
                        finally
                        {
                            if (arrayBaseHandle != null)
                            {
                                arrayBaseHandle.Dispose();
                            }
                        }
                    }
                }
            }

            if (GlobalLog.IsEnabled)
            {
                GlobalLog.Leave(nameof(EnumerateSecurityPackages));
            }
            return(secModule.SecurityPackages);
        }
Example #3
0
        internal static SecurityPackageInfoClass[] EnumerateSecurityPackages(SSPIInterface secModule)
        {
            GlobalLog.Enter("EnumerateSecurityPackages");
            if (secModule.SecurityPackages == null)
            {
                lock (secModule)
                {
                    if (secModule.SecurityPackages == null)
                    {
                        int moduleCount = 0;
                        SafeFreeContextBuffer arrayBaseHandle = null;
                        try
                        {
                            int errorCode = secModule.EnumerateSecurityPackages(out moduleCount, out arrayBaseHandle);
                            GlobalLog.Print("SSPIWrapper::arrayBase: " + (arrayBaseHandle.DangerousGetHandle().ToString("x")));
                            if (errorCode != 0)
                            {
                                throw new Win32Exception(errorCode);
                            }

                            SecurityPackageInfoClass[] securityPackages = new SecurityPackageInfoClass[moduleCount];
                            if (Logging.On)
                            {
                                Logging.PrintInfo(Logging.Web, SR.net_log_sspi_enumerating_security_packages);
                            }

                            int i;
                            for (i = 0; i < moduleCount; i++)
                            {
                                securityPackages[i] = new SecurityPackageInfoClass(arrayBaseHandle, i);
                                if (Logging.On)
                                {
                                    Logging.PrintInfo(Logging.Web, "    " + securityPackages[i].Name);
                                }
                            }

                            secModule.SecurityPackages = securityPackages;
                        }
                        finally
                        {
                            if (arrayBaseHandle != null)
                            {
                                arrayBaseHandle.Dispose();
                            }
                        }
                    }
                }
            }

            GlobalLog.Leave("EnumerateSecurityPackages");
            return(secModule.SecurityPackages);
        }
 internal static SecurityPackageInfoClass[] EnumerateSecurityPackages(SSPIInterface SecModule)
 {
     if (SecModule.SecurityPackages == null)
     {
         lock (SecModule)
         {
             if (SecModule.SecurityPackages == null)
             {
                 int pkgnum = 0;
                 SafeFreeContextBuffer pkgArray = null;
                 try
                 {
                     int error = SecModule.EnumerateSecurityPackages(out pkgnum, out pkgArray);
                     if (error != 0)
                     {
                         throw new Win32Exception(error);
                     }
                     SecurityPackageInfoClass[] classArray = new SecurityPackageInfoClass[pkgnum];
                     if (Logging.On)
                     {
                         Logging.PrintInfo(Logging.Web, SR.GetString("net_log_sspi_enumerating_security_packages"));
                     }
                     for (int i = 0; i < pkgnum; i++)
                     {
                         classArray[i] = new SecurityPackageInfoClass(pkgArray, i);
                         if (Logging.On)
                         {
                             Logging.PrintInfo(Logging.Web, "    " + classArray[i].Name);
                         }
                     }
                     SecModule.SecurityPackages = classArray;
                 }
                 finally
                 {
                     if (pkgArray != null)
                     {
                         pkgArray.Close();
                     }
                 }
             }
         }
     }
     return(SecModule.SecurityPackages);
 }
        // private static SecurityPackageInfoClass[] m_SecurityPackages;

        private static SecurityPackageInfoClass[] EnumerateSecurityPackages(SSPIInterface SecModule)
        {
            GlobalLog.Enter("EnumerateSecurityPackages");

            int    moduleCount = 0;
            IntPtr arrayBase   = IntPtr.Zero;

            int errorCode =
                SecModule.EnumerateSecurityPackages(
                    out moduleCount,
                    out arrayBase);

            GlobalLog.Print("SSPIWrapper::arrayBase: " + ((long)arrayBase).ToString());

            if (errorCode != 0)
            {
                throw new Win32Exception(errorCode);
            }

            SecurityPackageInfoClass[] securityPackages = new SecurityPackageInfoClass[moduleCount];

            int    i;
            IntPtr unmanagedPointer = arrayBase;

            for (i = 0; i < moduleCount; i++)
            {
                GlobalLog.Print("SSPIWrapper::unmanagedPointer: " + ((long)unmanagedPointer).ToString());
                securityPackages[i] = new SecurityPackageInfoClass(SecModule, unmanagedPointer);
                unmanagedPointer    = IntPtrHelper.Add(unmanagedPointer, SecurityPackageInfo.Size);
            }

            SecModule.FreeContextBuffer(arrayBase);

            GlobalLog.Leave("EnumerateSecurityPackages");
            return(securityPackages);
        }
 internal static SecurityPackageInfoClass[] EnumerateSecurityPackages(SSPIInterface SecModule)
 {
     if (SecModule.SecurityPackages == null)
     {
         lock (SecModule)
         {
             if (SecModule.SecurityPackages == null)
             {
                 int pkgnum = 0;
                 SafeFreeContextBuffer pkgArray = null;
                 try
                 {
                     int error = SecModule.EnumerateSecurityPackages(out pkgnum, out pkgArray);
                     if (error != 0)
                     {
                         throw new Win32Exception(error);
                     }
                     SecurityPackageInfoClass[] classArray = new SecurityPackageInfoClass[pkgnum];
                     if (Logging.On)
                     {
                         Logging.PrintInfo(Logging.Web, SR.GetString("net_log_sspi_enumerating_security_packages"));
                     }
                     for (int i = 0; i < pkgnum; i++)
                     {
                         classArray[i] = new SecurityPackageInfoClass(pkgArray, i);
                         if (Logging.On)
                         {
                             Logging.PrintInfo(Logging.Web, "    " + classArray[i].Name);
                         }
                     }
                     SecModule.SecurityPackages = classArray;
                 }
                 finally
                 {
                     if (pkgArray != null)
                     {
                         pkgArray.Close();
                     }
                 }
             }
         }
     }
     return SecModule.SecurityPackages;
 }