Exemplo n.º 1
0
 public LdapSearchRequest(int messageId, string baseDn, SearchScope scope, string filter, string[] attributes, bool attributesOnly, TimeSpan timeout, int sizeLimit, LdapControl[] controls)
     : base(messageId, controls)
 {
     if (timeout < TimeSpan.Zero)
     {
         throw new LdapProtocolException("invalid timeLimit");
     }
     if (sizeLimit < 0)
     {
         throw new LdapProtocolException("invalid sizeLimit");
     }
     BaseObject = new LdapDistinguishedName(baseDn);
     Scope      = scope;
     Filter     = LdapFilter.Parse(filter);
     if (attributes != null && attributes.Length > 0)
     {
         var ldapAttributes = new LdapAttributeSelection[attributes.Length];
         for (int i = 0; i < attributes.Length; i++)
         {
             ldapAttributes[i] = new LdapAttributeSelection(attributes[i]);
         }
         Attributes = ldapAttributes;
     }
     else
     {
         Attributes = Array.Empty <LdapAttributeSelection>();
     }
     TypesOnly = attributesOnly;
     TimeLimit = timeout;
     SizeLimit = sizeLimit;
 }
Exemplo n.º 2
0
        internal LdapNotFilter(LdapFilter filter)
        {
            if (filter is null)
            {
                throw new ArgumentNullException(nameof(filter));
            }

            Filter = filter;
        }
Exemplo n.º 3
0
        internal LdapOrFilter(Asn1Filter[] filter)
        {
            var ldapFilter = new LdapFilter[filter.Length];

            for (int i = 0; i < filter.Length; i++)
            {
                ldapFilter[i] = LdapFilter.Create(filter[i]);
            }
            Filter = ldapFilter;
        }
Exemplo n.º 4
0
        internal LdapSearchRequest(Asn1LdapMessage message)
            : base(message)
        {
            var search = message.ProtocolOp.SearchRequest;

            BaseObject   = new LdapDistinguishedName(search.BaseObject.Span);
            Scope        = search.Scope;
            DerefAliases = search.DerefAliases;
            if (DerefAliases < DerefAliases.NeverDerefAliases || DerefAliases > DerefAliases.DerefAlways)
            {
                throw new LdapProtocolException("invalid derefAliases");
            }
            SizeLimit = search.SizeLimit;
            if (SizeLimit == 0)
            {
                SizeLimit = Int32.MaxValue;
            }
            else if (SizeLimit < 0)
            {
                throw new LdapProtocolException("invalid sizeLimit");
            }
            TimeLimit = TimeSpan.FromSeconds(search.TimeLimit);
            if (TimeLimit < TimeSpan.Zero)
            {
                throw new LdapProtocolException("invalid timeLimit");
            }
            TypesOnly = search.TypesOnly;
            Filter    = LdapFilter.Create(search.Filter);
            if (search.Attributes.Length > 0)
            {
                var attributes = new LdapAttributeSelection[search.Attributes.Length];
                for (int i = 0; i < search.Attributes.Length; i++)
                {
                    attributes[i] = new LdapAttributeSelection(search.Attributes[i].Span);
                }
                Attributes = attributes;
            }
            else
            {
                Attributes = Array.Empty <LdapAttributeSelection>();
            }
        }
Exemplo n.º 5
0
 internal LdapNotFilter(Asn1Filter filter)
 {
     Filter = Create(filter);
 }