//************************************************************************* // 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 ; }
private void InitBlock(RfcFilter enclosingInstance) { this.enclosingInstance = enclosingInstance; }
public FilterIterator(RfcFilter enclosingInstance, Asn1Tagged root) { InitBlock(enclosingInstance); this.root = root; }
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 ; }
/// <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; } }