Exemplo n.º 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);
                }
            }
        }