Пример #1
0
 public SamrOpenDomain(Rpc.PolicyHandle handle, int accessMask, Rpc.SidT sid, Rpc.PolicyHandle
                       domainHandle)
 {
     this.Handle       = handle;
     this.AccessMask   = accessMask;
     this.Sid          = sid;
     this.DomainHandle = domainHandle;
 }
Пример #2
0
 public MsrpcSamrOpenDomain(SamrPolicyHandle handle,
                            int access,
                            Rpc.SidT sid,
                            SamrDomainHandle domainHandle)
     : base(handle, access, sid, domainHandle)
 {
     Ptype = 0;
     Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
 }
Пример #3
0
        /// <exception cref="System.IO.IOException"></exception>
        public SamrDomainHandle(DcerpcHandle handle, SamrPolicyHandle policyHandle, int access
                                , Rpc.SidT sid)
        {
            MsrpcSamrOpenDomain rpc = new MsrpcSamrOpenDomain(policyHandle, access, sid, this
                                                              );

            handle.Sendrecv(rpc);
            if (rpc.Retval != 0)
            {
                throw new SmbException(rpc.Retval, false);
            }
        }
Пример #4
0
            /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
            public override void Decode(NdrBuffer src)
            {
                src.Align(4);
                int sidp = src.Dec_ndr_long();

                if (sidp != 0)
                {
                    if (Sid == null)
                    {
                        Sid = new Rpc.SidT();
                    }
                    src = src.Deferred;
                    Sid.Decode(src);
                }
            }
Пример #5
0
        public static byte[] ToByteArray(Rpc.SidT sid)
        {
            byte[] dst = new byte[1 + 1 + 6 + sid.SubAuthorityCount * 4];
            int    di  = 0;

            dst[di++] = sid.Revision;
            dst[di++] = sid.SubAuthorityCount;
            Array.Copy(sid.IdentifierAuthority, 0, dst, di, 6);
            di += 6;
            for (int ii = 0; ii < sid.SubAuthorityCount; ii++)
            {
                Encdec.Enc_uint32le(sid.SubAuthority[ii], dst, di);
                di += 4;
            }
            return(dst);
        }
Пример #6
0
            /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
            public override void Decode(NdrBuffer src)
            {
                src.Align(4);
                src.Align(4);
                if (Name == null)
                {
                    Name = new Rpc.Unicode_string();
                }
                Name.Length        = (short)src.Dec_ndr_short();
                Name.MaximumLength = (short)src.Dec_ndr_short();
                int nameBufferp = src.Dec_ndr_long();
                int sidp        = src.Dec_ndr_long();

                if (nameBufferp != 0)
                {
                    src = src.Deferred;
                    int nameBuffers = src.Dec_ndr_long();
                    src.Dec_ndr_long();
                    int nameBufferl = src.Dec_ndr_long();
                    int nameBufferi = src.Index;
                    src.Advance(2 * nameBufferl);
                    if (Name.Buffer == null)
                    {
                        if (nameBuffers < 0 || nameBuffers > unchecked (0xFFFF))
                        {
                            throw new NdrException(NdrException.InvalidConformance);
                        }
                        Name.Buffer = new short[nameBuffers];
                    }
                    src = src.Derive(nameBufferi);
                    for (int i = 0; i < nameBufferl; i++)
                    {
                        Name.Buffer[i] = (short)src.Dec_ndr_short();
                    }
                }
                if (sidp != 0)
                {
                    if (Sid == null)
                    {
                        Sid = new Rpc.SidT();
                    }
                    src = src.Deferred;
                    Sid.Decode(src);
                }
            }
Пример #7
0
 public Sid(Rpc.SidT sid, int type, string domainName, string acctName, bool decrementAuthority
            )
 {
     Revision            = sid.Revision;
     SubAuthorityCount   = sid.SubAuthorityCount;
     IdentifierAuthority = sid.IdentifierAuthority;
     SubAuthority        = sid.SubAuthority;
     this.Type           = type;
     this.DomainName     = domainName;
     this.AcctName       = acctName;
     if (decrementAuthority)
     {
         SubAuthorityCount--;
         SubAuthority = new int[SubAuthorityCount];
         for (int i = 0; i < SubAuthorityCount; i++)
         {
             SubAuthority[i] = sid.SubAuthority[i];
         }
     }
 }
Пример #8
0
			public SamrOpenDomain(Rpc.PolicyHandle handle, int accessMask, Rpc.SidT sid, Rpc.PolicyHandle
				 domainHandle)
			{
				this.Handle = handle;
				this.AccessMask = accessMask;
				this.Sid = sid;
				this.DomainHandle = domainHandle;
			}
Пример #9
0
            /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
            public override void Decode(NdrBuffer src)
            {
                src.Align(4);
                src.Align(4);
                if (Name == null)
                {
                    Name = new Rpc.Unicode_string();
                }
                Name.Length        = (short)src.Dec_ndr_short();
                Name.MaximumLength = (short)src.Dec_ndr_short();
                int nameBufferp = src.Dec_ndr_long();

                src.Align(4);
                if (DnsDomain == null)
                {
                    DnsDomain = new Rpc.Unicode_string();
                }
                DnsDomain.Length        = (short)src.Dec_ndr_short();
                DnsDomain.MaximumLength = (short)src.Dec_ndr_short();
                int dnsDomainBufferp = src.Dec_ndr_long();

                src.Align(4);
                if (DnsForest == null)
                {
                    DnsForest = new Rpc.Unicode_string();
                }
                DnsForest.Length        = (short)src.Dec_ndr_short();
                DnsForest.MaximumLength = (short)src.Dec_ndr_short();
                int dnsForestBufferp = src.Dec_ndr_long();

                src.Align(4);
                if (DomainGuid == null)
                {
                    DomainGuid = new Rpc.UuidT();
                }
                DomainGuid.TimeLow               = src.Dec_ndr_long();
                DomainGuid.TimeMid               = (short)src.Dec_ndr_short();
                DomainGuid.TimeHiAndVersion      = (short)src.Dec_ndr_short();
                DomainGuid.ClockSeqHiAndReserved = unchecked ((byte)src.Dec_ndr_small());
                DomainGuid.ClockSeqLow           = unchecked ((byte)src.Dec_ndr_small());
                int domainGuidNodes = 6;
                int domainGuidNodei = src.Index;

                src.Advance(1 * domainGuidNodes);
                int sidp = src.Dec_ndr_long();

                if (nameBufferp != 0)
                {
                    src = src.Deferred;
                    int nameBuffers = src.Dec_ndr_long();
                    src.Dec_ndr_long();
                    int nameBufferl = src.Dec_ndr_long();
                    int nameBufferi = src.Index;
                    src.Advance(2 * nameBufferl);
                    if (Name.Buffer == null)
                    {
                        if (nameBuffers < 0 || nameBuffers > unchecked (0xFFFF))
                        {
                            throw new NdrException(NdrException.InvalidConformance);
                        }
                        Name.Buffer = new short[nameBuffers];
                    }
                    src = src.Derive(nameBufferi);
                    for (int i = 0; i < nameBufferl; i++)
                    {
                        Name.Buffer[i] = (short)src.Dec_ndr_short();
                    }
                }
                if (dnsDomainBufferp != 0)
                {
                    src = src.Deferred;
                    int dnsDomainBuffers = src.Dec_ndr_long();
                    src.Dec_ndr_long();
                    int dnsDomainBufferl = src.Dec_ndr_long();
                    int dnsDomainBufferi = src.Index;
                    src.Advance(2 * dnsDomainBufferl);
                    if (DnsDomain.Buffer == null)
                    {
                        if (dnsDomainBuffers < 0 || dnsDomainBuffers > unchecked (0xFFFF))
                        {
                            throw new NdrException(NdrException.InvalidConformance);
                        }
                        DnsDomain.Buffer = new short[dnsDomainBuffers];
                    }
                    src = src.Derive(dnsDomainBufferi);
                    for (int i = 0; i < dnsDomainBufferl; i++)
                    {
                        DnsDomain.Buffer[i] = (short)src.Dec_ndr_short();
                    }
                }
                if (dnsForestBufferp != 0)
                {
                    src = src.Deferred;
                    int dnsForestBuffers = src.Dec_ndr_long();
                    src.Dec_ndr_long();
                    int dnsForestBufferl = src.Dec_ndr_long();
                    int dnsForestBufferi = src.Index;
                    src.Advance(2 * dnsForestBufferl);
                    if (DnsForest.Buffer == null)
                    {
                        if (dnsForestBuffers < 0 || dnsForestBuffers > unchecked (0xFFFF))
                        {
                            throw new NdrException(NdrException.InvalidConformance);
                        }
                        DnsForest.Buffer = new short[dnsForestBuffers];
                    }
                    src = src.Derive(dnsForestBufferi);
                    for (int i = 0; i < dnsForestBufferl; i++)
                    {
                        DnsForest.Buffer[i] = (short)src.Dec_ndr_short();
                    }
                }
                if (DomainGuid.Node == null)
                {
                    if (domainGuidNodes < 0 || domainGuidNodes > unchecked (0xFFFF))
                    {
                        throw new NdrException(NdrException.InvalidConformance);
                    }
                    DomainGuid.Node = new byte[domainGuidNodes];
                }
                src = src.Derive(domainGuidNodei);
                for (int i1 = 0; i1 < domainGuidNodes; i1++)
                {
                    DomainGuid.Node[i1] = unchecked ((byte)src.Dec_ndr_small());
                }
                if (sidp != 0)
                {
                    if (Sid == null)
                    {
                        Sid = new Rpc.SidT();
                    }
                    src = src.Deferred;
                    Sid.Decode(src);
                }
            }
Пример #10
0
			/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
			public override void Decode(NdrBuffer src)
			{
				src.Align(4);
				src.Align(4);
				if (Name == null)
				{
					Name = new Rpc.Unicode_string();
				}
				Name.Length = (short)src.Dec_ndr_short();
				Name.MaximumLength = (short)src.Dec_ndr_short();
				int nameBufferp = src.Dec_ndr_long();
				int sidp = src.Dec_ndr_long();
				if (nameBufferp != 0)
				{
					src = src.Deferred;
					int nameBuffers = src.Dec_ndr_long();
					src.Dec_ndr_long();
					int nameBufferl = src.Dec_ndr_long();
					int nameBufferi = src.Index;
					src.Advance(2 * nameBufferl);
					if (Name.Buffer == null)
					{
						if (nameBuffers < 0 || nameBuffers > unchecked(0xFFFF))
						{
							throw new NdrException(NdrException.InvalidConformance);
						}
						Name.Buffer = new short[nameBuffers];
					}
					src = src.Derive(nameBufferi);
					for (int i = 0; i < nameBufferl; i++)
					{
						Name.Buffer[i] = (short)src.Dec_ndr_short();
					}
				}
				if (sidp != 0)
				{
					if (Sid == null)
					{
						Sid = new Rpc.SidT();
					}
					src = src.Deferred;
					Sid.Decode(src);
				}
			}
Пример #11
0
			/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
			public override void Decode(NdrBuffer src)
			{
				src.Align(4);
				int sidp = src.Dec_ndr_long();
				if (sidp != 0)
				{
					if (Sid == null)
					{
						Sid = new Rpc.SidT();
					}
					src = src.Deferred;
					Sid.Decode(src);
				}
			}
Пример #12
0
			/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
			public override void Decode(NdrBuffer src)
			{
				src.Align(4);
				src.Align(4);
				if (Name == null)
				{
					Name = new Rpc.Unicode_string();
				}
				Name.Length = (short)src.Dec_ndr_short();
				Name.MaximumLength = (short)src.Dec_ndr_short();
				int nameBufferp = src.Dec_ndr_long();
				src.Align(4);
				if (DnsDomain == null)
				{
					DnsDomain = new Rpc.Unicode_string();
				}
				DnsDomain.Length = (short)src.Dec_ndr_short();
				DnsDomain.MaximumLength = (short)src.Dec_ndr_short();
				int dnsDomainBufferp = src.Dec_ndr_long();
				src.Align(4);
				if (DnsForest == null)
				{
					DnsForest = new Rpc.Unicode_string();
				}
				DnsForest.Length = (short)src.Dec_ndr_short();
				DnsForest.MaximumLength = (short)src.Dec_ndr_short();
				int dnsForestBufferp = src.Dec_ndr_long();
				src.Align(4);
				if (DomainGuid == null)
				{
					DomainGuid = new Rpc.UuidT();
				}
				DomainGuid.TimeLow = src.Dec_ndr_long();
				DomainGuid.TimeMid = (short)src.Dec_ndr_short();
				DomainGuid.TimeHiAndVersion = (short)src.Dec_ndr_short();
				DomainGuid.ClockSeqHiAndReserved = unchecked((byte)src.Dec_ndr_small());
				DomainGuid.ClockSeqLow = unchecked((byte)src.Dec_ndr_small());
				int domainGuidNodes = 6;
				int domainGuidNodei = src.Index;
				src.Advance(1 * domainGuidNodes);
				int sidp = src.Dec_ndr_long();
				if (nameBufferp != 0)
				{
					src = src.Deferred;
					int nameBuffers = src.Dec_ndr_long();
					src.Dec_ndr_long();
					int nameBufferl = src.Dec_ndr_long();
					int nameBufferi = src.Index;
					src.Advance(2 * nameBufferl);
					if (Name.Buffer == null)
					{
						if (nameBuffers < 0 || nameBuffers > unchecked(0xFFFF))
						{
							throw new NdrException(NdrException.InvalidConformance);
						}
						Name.Buffer = new short[nameBuffers];
					}
					src = src.Derive(nameBufferi);
					for (int i = 0; i < nameBufferl; i++)
					{
						Name.Buffer[i] = (short)src.Dec_ndr_short();
					}
				}
				if (dnsDomainBufferp != 0)
				{
					src = src.Deferred;
					int dnsDomainBuffers = src.Dec_ndr_long();
					src.Dec_ndr_long();
					int dnsDomainBufferl = src.Dec_ndr_long();
					int dnsDomainBufferi = src.Index;
					src.Advance(2 * dnsDomainBufferl);
					if (DnsDomain.Buffer == null)
					{
						if (dnsDomainBuffers < 0 || dnsDomainBuffers > unchecked(0xFFFF))
						{
							throw new NdrException(NdrException.InvalidConformance);
						}
						DnsDomain.Buffer = new short[dnsDomainBuffers];
					}
					src = src.Derive(dnsDomainBufferi);
					for (int i = 0; i < dnsDomainBufferl; i++)
					{
						DnsDomain.Buffer[i] = (short)src.Dec_ndr_short();
					}
				}
				if (dnsForestBufferp != 0)
				{
					src = src.Deferred;
					int dnsForestBuffers = src.Dec_ndr_long();
					src.Dec_ndr_long();
					int dnsForestBufferl = src.Dec_ndr_long();
					int dnsForestBufferi = src.Index;
					src.Advance(2 * dnsForestBufferl);
					if (DnsForest.Buffer == null)
					{
						if (dnsForestBuffers < 0 || dnsForestBuffers > unchecked(0xFFFF))
						{
							throw new NdrException(NdrException.InvalidConformance);
						}
						DnsForest.Buffer = new short[dnsForestBuffers];
					}
					src = src.Derive(dnsForestBufferi);
					for (int i = 0; i < dnsForestBufferl; i++)
					{
						DnsForest.Buffer[i] = (short)src.Dec_ndr_short();
					}
				}
				if (DomainGuid.Node == null)
				{
					if (domainGuidNodes < 0 || domainGuidNodes > unchecked(0xFFFF))
					{
						throw new NdrException(NdrException.InvalidConformance);
					}
					DomainGuid.Node = new byte[domainGuidNodes];
				}
				src = src.Derive(domainGuidNodei);
				for (int i1 = 0; i1 < domainGuidNodes; i1++)
				{
					DomainGuid.Node[i1] = unchecked((byte)src.Dec_ndr_small());
				}
				if (sidp != 0)
				{
					if (Sid == null)
					{
						Sid = new Rpc.SidT();
					}
					src = src.Deferred;
					Sid.Decode(src);
				}
			}