Represents an Ldap Filter. This filter object can be created from a String or can be built up programatically by adding filter components one at a time. Existing filter components can be iterated though. Each filter component has an integer identifier defined in this class. The following are basic filter components: {@link #EQUALITY_MATCH}, {@link #GREATER_OR_EQUAL}, {@link #LESS_OR_EQUAL}, {@link #SUBSTRINGS}, {@link #PRESENT}, {@link #APPROX_MATCH}, {@link #EXTENSIBLE_MATCH}. More filters can be nested together into more complex filters with the following filter components: {@link #AND}, {@link #OR}, {@link #NOT} Substrings can have three components:
 Filter ::= CHOICE { and             [0] SET OF Filter, or              [1] SET OF Filter, not             [2] Filter, equalityMatch   [3] AttributeValueAssertion, substrings      [4] SubstringFilter, greaterOrEqual  [5] AttributeValueAssertion, lessOrEqual     [6] AttributeValueAssertion, present         [7] AttributeDescription, approxMatch     [8] AttributeValueAssertion, extensibleMatch [9] MatchingRuleAssertion } 
Inheritance: Novell.Directory.Ldap.Asn1.Asn1Choice
Example #1
0
		//*************************************************************************
		// Constructors for SearchRequest
		//*************************************************************************
		
		/*
		*
		*/
		public RfcSearchRequest(RfcLdapDN baseObject, Asn1Enumerated scope, Asn1Enumerated derefAliases, Asn1Integer sizeLimit, Asn1Integer timeLimit, Asn1Boolean typesOnly, RfcFilter filter, RfcAttributeDescriptionList attributes):base(8)
		{
			add(baseObject);
			add(scope);
			add(derefAliases);
			add(sizeLimit);
			add(timeLimit);
			add(typesOnly);
			add(filter);
			add(attributes);
			return ;
		}
Example #2
0
 private void InitBlock(RfcFilter enclosingInstance)
 {
     this.enclosingInstance = enclosingInstance;
 }
Example #3
0
 public FilterIterator(RfcFilter enclosingInstance, Asn1Tagged root)
 {
     InitBlock(enclosingInstance);
     this.root = root;
 }
Example #4
0
            private int offset; // Offset pointer into the filter string

            #endregion Fields

            #region Constructors

            //*************************************************************************
            // Constructor
            //*************************************************************************
            /// <summary> Constructs a FilterTokenizer for a filter.</summary>
            public FilterTokenizer(RfcFilter enclosingInstance, System.String filter)
            {
                InitBlock(enclosingInstance);
                this.filter = filter;
                this.offset = 0;
                this.filterLength = filter.Length;
                return ;
            }
 /// <summary> Constructs an Ldap Search Request with a filter in Asn1 format.
 /// 
 /// </summary>
 /// <param name="base">          The base distinguished name to search from.
 /// 
 /// </param>
 /// <param name="scope">         The scope of the entries to search. The following
 /// are the valid options:
 /// <ul>
 /// <li>SCOPE_BASE - searches only the base DN</li>
 /// 
 /// <li>SCOPE_ONE - searches only entries under the base DN</li>
 /// 
 /// <li>SCOPE_SUB - searches the base DN and all entries
 /// within its subtree</li>
 /// </ul>
 /// </param>
 /// <param name="filter">        The search filter specifying the search criteria.
 /// 
 /// </param>
 /// <param name="attrs">         The names of attributes to retrieve.
 /// operation exceeds the time limit.
 /// 
 /// </param>
 /// <param name="dereference">Specifies when aliases should be dereferenced.
 /// Must be either one of the constants defined in
 /// LdapConstraints, which are DEREF_NEVER,
 /// DEREF_FINDING, DEREF_SEARCHING, or DEREF_ALWAYS.
 /// 
 /// </param>
 /// <param name="maxResults">The maximum number of search results to return
 /// for a search request.
 /// The search operation will be terminated by the server
 /// with an LdapException.SIZE_LIMIT_EXCEEDED if the
 /// number of results exceed the maximum.
 /// 
 /// </param>
 /// <param name="serverTimeLimit">The maximum time in seconds that the server
 /// should spend returning search results. This is a
 /// server-enforced limit.  A value of 0 means
 /// no time limit.
 /// 
 /// </param>
 /// <param name="typesOnly">     If true, returns the names but not the values of
 /// the attributes found.  If false, returns the
 /// names and values for attributes found.
 /// 
 /// </param>
 /// <param name="cont">           Any controls that apply to the search request.
 /// or null if none.
 /// 
 /// </param>
 /// <seealso cref="Novell.Directory.Ldap.LdapConnection.Search">
 /// </seealso>
 /// <seealso cref="Novell.Directory.Ldap.LdapSearchConstraints">
 /// </seealso>
 public LdapSearchRequest(System.String base_Renamed, int scope, RfcFilter filter, System.String[] attrs, int dereference, int maxResults, int serverTimeLimit, bool typesOnly, LdapControl[] cont)
     : base(LdapMessage.SEARCH_REQUEST, new RfcSearchRequest(new RfcLdapDN(base_Renamed), new Asn1Enumerated(scope), new Asn1Enumerated(dereference), new Asn1Integer(maxResults), new Asn1Integer(serverTimeLimit), new Asn1Boolean(typesOnly), filter, new RfcAttributeDescriptionList(attrs)), cont)
 {
     return ;
 }
Example #6
0
        /// <summary>Searches the directory
        /// </summary>
        /// <param name="searchBase">Where to start the search</param>
        /// <param name="searchScope">Scope of search</param>
        /// <param name="searchFilter">Filter to search for</param>
        /// <param name="searchAttrs">Attributes to search for</param>
        /// <returns>List of entries matching filter</returns>
        public LdapEntry[] Search(string searchBase, int searchScope, string searchFilter, string[] searchAttrs)
        {
            if (!conn.Connected)
                return null;

            try {

                List<LdapEntry> retVal = new List<LdapEntry> ();
                RfcFilter rfcFilter = new RfcFilter (searchFilter);

                LdapSearchConstraints cons = new LdapSearchConstraints ();
                cons.MaxResults = 0;

                LdapSearchQueue queue = conn.Search (searchBase,
                        searchScope,
                        rfcFilter.filterToString(),
                        searchAttrs,
                        false,
                        (LdapSearchQueue) null,
                        cons);

                LdapMessage msg;

                while ((msg = queue.getResponse ()) != null) {

                    if (msg is LdapSearchResult) {
                        LdapEntry entry = ((LdapSearchResult) msg).Entry;
                        retVal.Add (entry);
                    }
                }

                return retVal.ToArray ();

            } catch (Exception e) {

                Log.Debug (e);
                return null;
            }
        }