예제 #1
0
        // 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);
        }