Example #1
0
        public static List <SID> LsaLookupNames(RPCCallHelper rpc, LsaHandle handle, List <string> names, out NTStatus status)
        {
            LsarLookupNamesRequest lookupNamesRequest = new LsarLookupNamesRequest();

            lookupNamesRequest.handle = handle;
            lookupNamesRequest.Names  = new NDRConformantArray <LsaUnicodeString>();
            foreach (string name in names)
            {
                lookupNamesRequest.Names.Add(new LsaUnicodeString(name));
            }
            lookupNamesRequest.TranslatedSids = new LsaTranslatedArray <LsaTranslatedSid>();

            LsarLookupNamesResponse lookupNamesResponse;

            status = rpc.ExecuteCall((ushort)LsaRemoteServiceOpName.LsarLookupNames, lookupNamesRequest, out lookupNamesResponse);
            if (status != NTStatus.STATUS_SUCCESS)
            {
                return(null);
            }
            if (names.Count != lookupNamesResponse.TranslatedNames.Items.Count)
            {
                status = NTStatus.STATUS_NOT_SUPPORTED;
                return(null);
            }
            List <SID> output = new List <SID>();

            foreach (LsaTranslatedSid sid in lookupNamesResponse.TranslatedNames.Items)
            {
                if (sid.Use == LsaSIDNameUse.SidTypeUnknown)
                {
                    output.Add(null);
                }
                else
                {
                    output.Add(sid.GetSID(lookupNamesResponse.DomainList.Names[(int)sid.DomainIndex].Sid));
                }
            }
            return(output);
        }
        internal static LsaRequestStub CreateLsaRequestStub(LsaMethodOpnums opnum)
        {
            LsaRequestStub requestStub = null;

            switch (opnum)
            {
            case LsaMethodOpnums.LsarClose:
                requestStub = new LsarCloseRequest();
                break;

            case LsaMethodOpnums.Opnum1NotUsedOnWire:
                requestStub = new Opnum1NotUsedOnWireRequest();
                break;

            case LsaMethodOpnums.LsarEnumeratePrivileges:
                requestStub = new LsarEnumeratePrivilegesRequest();
                break;

            case LsaMethodOpnums.LsarQuerySecurityObject:
                requestStub = new LsarQuerySecurityObjectRequest();
                break;

            case LsaMethodOpnums.LsarSetSecurityObject:
                requestStub = new LsarSetSecurityObjectRequest();
                break;

            case LsaMethodOpnums.Opnum5NotUsedOnWire:
                requestStub = new Opnum5NotUsedOnWireRequest();
                break;

            case LsaMethodOpnums.LsarOpenPolicy:
                requestStub = new LsarOpenPolicyRequest();
                break;

            case LsaMethodOpnums.LsarQueryInformationPolicy:
                requestStub = new LsarQueryInformationPolicyRequest();
                break;

            case LsaMethodOpnums.LsarSetInformationPolicy:
                requestStub = new LsarSetInformationPolicyRequest();
                break;

            case LsaMethodOpnums.Opnum9NotUsedOnWire:
                requestStub = new Opnum9NotUsedOnWireRequest();
                break;

            case LsaMethodOpnums.LsarCreateAccount:
                requestStub = new LsarCreateAccountRequest();
                break;

            case LsaMethodOpnums.LsarEnumerateAccounts:
                requestStub = new LsarEnumerateAccountsRequest();
                break;

            case LsaMethodOpnums.LsarCreateTrustedDomain:
                requestStub = new LsarCreateTrustedDomainRequest();
                break;

            case LsaMethodOpnums.LsarEnumerateTrustedDomains:
                requestStub = new LsarEnumerateTrustedDomainsRequest();
                break;

            case LsaMethodOpnums.LsarLookupNames:
                requestStub = new LsarLookupNamesRequest();
                break;

            case LsaMethodOpnums.LsarLookupSids:
                requestStub = new LsarLookupSidsRequest();
                break;

            case LsaMethodOpnums.LsarCreateSecret:
                requestStub = new LsarCreateSecretRequest();
                break;

            case LsaMethodOpnums.LsarOpenAccount:
                requestStub = new LsarOpenAccountRequest();
                break;

            case LsaMethodOpnums.LsarEnumeratePrivilegesAccount:
                requestStub = new LsarEnumeratePrivilegesAccountRequest();
                break;

            case LsaMethodOpnums.LsarAddPrivilegesToAccount:
                requestStub = new LsarAddPrivilegesToAccountRequest();
                break;

            case LsaMethodOpnums.LsarRemovePrivilegesFromAccount:
                requestStub = new LsarRemovePrivilegesFromAccountRequest();
                break;

            case LsaMethodOpnums.Opnum21NotUsedOnWire:
                requestStub = new Opnum21NotUsedOnWireRequest();
                break;

            case LsaMethodOpnums.Opnum22NotUsedOnWire:
                requestStub = new Opnum22NotUsedOnWireRequest();
                break;

            case LsaMethodOpnums.LsarGetSystemAccessAccount:
                requestStub = new LsarGetSystemAccessAccountRequest();
                break;

            case LsaMethodOpnums.LsarSetSystemAccessAccount:
                requestStub = new LsarSetSystemAccessAccountRequest();
                break;

            case LsaMethodOpnums.LsarOpenTrustedDomain:
                requestStub = new LsarOpenTrustedDomainRequest();
                break;

            case LsaMethodOpnums.LsarQueryInfoTrustedDomain:
                requestStub = new LsarQueryInfoTrustedDomainRequest();
                break;

            case LsaMethodOpnums.LsarSetInformationTrustedDomain:
                requestStub = new LsarSetInformationTrustedDomainRequest();
                break;

            case LsaMethodOpnums.LsarOpenSecret:
                requestStub = new LsarOpenSecretRequest();
                break;

            case LsaMethodOpnums.LsarSetSecret:
                requestStub = new LsarSetSecretRequest();
                break;

            case LsaMethodOpnums.LsarQuerySecret:
                requestStub = new LsarQuerySecretRequest();
                break;

            case LsaMethodOpnums.LsarLookupPrivilegeValue:
                requestStub = new LsarLookupPrivilegeValueRequest();
                break;

            case LsaMethodOpnums.LsarLookupPrivilegeName:
                requestStub = new LsarLookupPrivilegeNameRequest();
                break;

            case LsaMethodOpnums.LsarLookupPrivilegeDisplayName:
                requestStub = new LsarLookupPrivilegeDisplayNameRequest();
                break;

            case LsaMethodOpnums.LsarDeleteObject:
                requestStub = new LsarDeleteObjectRequest();
                break;

            case LsaMethodOpnums.LsarEnumerateAccountsWithUserRight:
                requestStub = new LsarEnumerateAccountsWithUserRightRequest();
                break;

            case LsaMethodOpnums.LsarEnumerateAccountRights:
                requestStub = new LsarEnumerateAccountRightsRequest();
                break;

            case LsaMethodOpnums.LsarAddAccountRights:
                requestStub = new LsarAddAccountRightsRequest();
                break;

            case LsaMethodOpnums.LsarRemoveAccountRights:
                requestStub = new LsarRemoveAccountRightsRequest();
                break;

            case LsaMethodOpnums.LsarQueryTrustedDomainInfo:
                requestStub = new LsarQueryTrustedDomainInfoRequest();
                break;

            case LsaMethodOpnums.LsarSetTrustedDomainInfo:
                requestStub = new LsarSetTrustedDomainInfoRequest();
                break;

            case LsaMethodOpnums.LsarDeleteTrustedDomain:
                requestStub = new LsarDeleteTrustedDomainRequest();
                break;

            case LsaMethodOpnums.LsarStorePrivateData:
                requestStub = new LsarStorePrivateDataRequest();
                break;

            case LsaMethodOpnums.LsarRetrievePrivateData:
                requestStub = new LsarRetrievePrivateDataRequest();
                break;

            case LsaMethodOpnums.LsarOpenPolicy2:
                requestStub = new LsarOpenPolicy2Request();
                break;

            case LsaMethodOpnums.LsarGetUserName:
                requestStub = new LsarGetUserNameRequest();
                break;

            case LsaMethodOpnums.LsarQueryInformationPolicy2:
                requestStub = new LsarQueryInformationPolicy2Request();
                break;

            case LsaMethodOpnums.LsarSetInformationPolicy2:
                requestStub = new LsarSetInformationPolicy2Request();
                break;

            case LsaMethodOpnums.LsarQueryTrustedDomainInfoByName:
                requestStub = new LsarQueryTrustedDomainInfoByNameRequest();
                break;

            case LsaMethodOpnums.LsarSetTrustedDomainInfoByName:
                requestStub = new LsarSetTrustedDomainInfoByNameRequest();
                break;

            case LsaMethodOpnums.LsarEnumerateTrustedDomainsEx:
                requestStub = new LsarEnumerateTrustedDomainsExRequest();
                break;

            case LsaMethodOpnums.LsarCreateTrustedDomainEx:
                requestStub = new LsarCreateTrustedDomainExRequest();
                break;

            case LsaMethodOpnums.Opnum52NotUsedOnWire:
                requestStub = new Opnum52NotUsedOnWireRequest();
                break;

            case LsaMethodOpnums.LsarQueryDomainInformationPolicy:
                requestStub = new LsarQueryDomainInformationPolicyRequest();
                break;

            case LsaMethodOpnums.LsarSetDomainInformationPolicy:
                requestStub = new LsarSetDomainInformationPolicyRequest();
                break;

            case LsaMethodOpnums.LsarOpenTrustedDomainByName:
                requestStub = new LsarOpenTrustedDomainByNameRequest();
                break;

            case LsaMethodOpnums.Opnum56NotUsedOnWire:
                requestStub = new Opnum56NotUsedOnWireRequest();
                break;

            case LsaMethodOpnums.LsarLookupSids2:
                requestStub = new LsarLookupSids2Request();
                break;

            case LsaMethodOpnums.LsarLookupNames2:
                requestStub = new LsarLookupNames2Request();
                break;

            case LsaMethodOpnums.LsarCreateTrustedDomainEx2:
                requestStub = new LsarCreateTrustedDomainEx2Request();
                break;

            case LsaMethodOpnums.Opnum60NotUsedOnWire:
                requestStub = new Opnum60NotUsedOnWireRequest();
                break;

            case LsaMethodOpnums.Opnum61NotUsedOnWire:
                requestStub = new Opnum61NotUsedOnWireRequest();
                break;

            case LsaMethodOpnums.Opnum62NotUsedOnWire:
                requestStub = new Opnum62NotUsedOnWireRequest();
                break;

            case LsaMethodOpnums.Opnum63NotUsedOnWire:
                requestStub = new Opnum63NotUsedOnWireRequest();
                break;

            case LsaMethodOpnums.Opnum64NotUsedOnWire:
                requestStub = new Opnum64NotUsedOnWireRequest();
                break;

            case LsaMethodOpnums.Opnum65NotUsedOnWire:
                requestStub = new Opnum65NotUsedOnWireRequest();
                break;

            case LsaMethodOpnums.Opnum66NotUsedOnWire:
                requestStub = new Opnum66NotUsedOnWireRequest();
                break;

            case LsaMethodOpnums.Opnum67NotUsedOnWire:
                requestStub = new Opnum67NotUsedOnWireRequest();
                break;

            case LsaMethodOpnums.LsarLookupNames3:
                requestStub = new LsarLookupNames3Request();
                break;

            case LsaMethodOpnums.Opnum69NotUsedOnWire:
                requestStub = new Opnum69NotUsedOnWireRequest();
                break;

            case LsaMethodOpnums.Opnum70NotUsedOnWire:
                requestStub = new Opnum70NotUsedOnWireRequest();
                break;

            case LsaMethodOpnums.Opnum71NotUsedOnWire:
                requestStub = new Opnum71NotUsedOnWireRequest();
                break;

            case LsaMethodOpnums.Opnum72NotUsedOnWire:
                requestStub = new Opnum72NotUsedOnWireRequest();
                break;

            case LsaMethodOpnums.LsarQueryForestTrustInformation:
                requestStub = new LsarQueryForestTrustInformationRequest();
                break;

            case LsaMethodOpnums.LsarSetForestTrustInformation:
                requestStub = new LsarSetForestTrustInformationRequest();
                break;

            case LsaMethodOpnums.Opnum75NotUsedOnWire:
                requestStub = new Opnum75NotUsedOnWireRequest();
                break;

            case LsaMethodOpnums.LsarLookupSids3:
                requestStub = new LsarLookupSids3Request();
                break;

            case LsaMethodOpnums.LsarLookupNames4:
                requestStub = new LsarLookupNames4Request();
                break;
            }

            return(requestStub);
        }