コード例 #1
0
        protected void LoadInternal(string target)
        {
            this.Messages = new List <string> {
            };

            this.Privileges = new List <PrivilegeAndPrincipals> {
            };

            this.IsDisposed = false;

            this.Success = false;

            this.PolicyHandle = IntPtr.Zero;

            IntPtr temphandle = IntPtr.Zero;

            LSA_OBJECT_ATTRIBUTES lsainfo = NativeHelper.InitLSAObjectAttributes();

            LSA_UNICODE_STRING systemname = (target == null) ? default(LSA_UNICODE_STRING) : NativeHelper.InitLSAString(target);

            uint rc = Advapi32.LsaOpenPolicy(systemname, ref lsainfo, LSA_POLICY_ACCESS.POLICY_ALL_ACCESS, out temphandle);

            this.Success = (rc == 0);

            if (this.Success)
            {
                this.PolicyHandle = temphandle;

                List <string> privlist = NativeHelper.GetPrivilegeList();

                foreach (string priv in privlist)
                {
                    GetPrivilegeAndPrincipals(priv);
                }
            }

            else
            {
                string errmsg = null;

                if (NativeHelper.GetLastError(out errmsg) != 0)
                {
                    Messages.Add("\tLsaOpenPolicy: " + errmsg);
                }
            }
        }
コード例 #2
0
        public static LSA_OBJECT_ATTRIBUTES InitLSAObjectAttributes()
        {
            LSA_OBJECT_ATTRIBUTES ret = new LSA_OBJECT_ATTRIBUTES();

            ret.Length = (ulong)Marshal.SizeOf(typeof(LSA_OBJECT_ATTRIBUTES));

            ret.RootDirectory = IntPtr.Zero;

            ret.ObjectName = IntPtr.Zero;

            ret.Attributes = 0;

            ret.SecurityDescriptor = IntPtr.Zero;

            ret.SecurityQualityOfService = IntPtr.Zero;

            return(ret);
        }
コード例 #3
0
 internal static extern uint LsaOpenPolicy(LSA_UNICODE_STRING SystemName,
                                           ref LSA_OBJECT_ATTRIBUTES ObjectAttributes,
                                           LSA_POLICY_ACCESS AccessMask,
                                           out IntPtr PolicyHandle);