private AuthenticationPackage(SecPkgInfo pkg) { Capabilities = pkg.fCapabilities; Version = pkg.wVersion; RpcId = pkg.wRPCID; MaxTokenSize = pkg.cbMaxToken; Name = pkg.Name; Comment = pkg.Comment; }
/// <summary> /// Get authentication packages. /// </summary> /// <returns>The list of authentication packages.</returns> public static IEnumerable <AuthenticationPackage> Get() { List <AuthenticationPackage> packages = new List <AuthenticationPackage>(); if (SecurityNativeMethods.EnumerateSecurityPackages(out int count, out IntPtr ppPackageInfo) == SecStatusCode.Success) { try { int size = Marshal.SizeOf(typeof(SecPkgInfo)); for (int i = 0; i < count; ++i) { SecPkgInfo pkg = (SecPkgInfo)Marshal.PtrToStructure(ppPackageInfo + i * size, typeof(SecPkgInfo)); packages.Add(new AuthenticationPackage(pkg)); } } finally { SecurityNativeMethods.FreeContextBuffer(ppPackageInfo); } } return(packages.AsReadOnly()); }