Novell.Directory.Ldap.LdapConnection.Search C# (CSharp) Method

Search() public method

Asynchronously performs the search specified by the parameters.
LdapException A general exception which includes an error /// message and an Ldap error code. ///
public Search ( System base_Renamed, int scope, System filter, System attrs, bool typesOnly, LdapSearchQueue queue ) : LdapSearchQueue
base_Renamed System
scope int The scope of the entries to search. The following /// are the valid options: ///
    ///
  • SCOPE_BASE - searches only the base DN
  • /// ///
  • SCOPE_ONE - searches only entries under the base DN
  • /// ///
  • SCOPE_SUB - searches the base DN and all entries /// within its subtree
  • ///
///
filter System Search filter specifying the search criteria. /// ///
attrs System Names of attributes to retrieve. /// ///
typesOnly bool If true, returns the names but not the values of /// the attributes found. If false, returns the /// names and values for attributes found. /// ///
queue LdapSearchQueue Handler for messages returned from a server in /// response to this request. If it is null, a /// queue object is created internally. /// ///
return LdapSearchQueue
        public virtual LdapSearchQueue Search(System.String base_Renamed, int scope, System.String filter, System.String[] attrs, bool typesOnly, LdapSearchQueue queue)
        {
            return Search(base_Renamed, scope, filter, attrs, typesOnly, queue, defSearchCons);
        }

Same methods

LdapConnection::Search ( System base_Renamed, int scope, System filter, System attrs, bool typesOnly, LdapSearchQueue queue, LdapSearchConstraints cons ) : LdapSearchQueue
LdapConnection::Search ( LdapUrl toGet ) : LdapSearchResults
LdapConnection::Search ( LdapUrl toGet, LdapSearchConstraints cons ) : LdapSearchResults
LdapConnection::Search ( System base_Renamed, int scope, System filter, System attrs, bool typesOnly ) : LdapSearchResults
LdapConnection::Search ( System base_Renamed, int scope, System filter, System attrs, bool typesOnly, LdapSearchConstraints cons ) : LdapSearchResults

Usage Example

Example #1
2
    // read and print search results
    public static bool searchDynamicGroupEntry( LdapConnection lc,
        String searchBase)
    {
        bool status = true;
        int searchScope = LdapConnection.SCOPE_BASE;
        String[] attrList = new String[]{"member"};
        String searchFilter = "(objectclass=*)";

        /* Since reading members of a dynamic group could potentially involve
         * a significant directory search, we use a timeout. Setting
         * time out to 10 seconds
         */
        LdapSearchConstraints cons = new LdapSearchConstraints();
        cons.TimeLimit = 10000 ;

        try
        {
            LdapSearchResults searchResults =
                lc.Search(  searchBase,
                searchScope,
                searchFilter,
                attrList,          // return only "member" attr
                false,             // return attrs and values
                cons );            // time out value

            LdapEntry nextEntry = null ;
            // Read and print search results.  We expect only one entry */
            if (( nextEntry = searchResults.next()) != null )
            {
                LdapAttributeSet attributeSet = nextEntry.getAttributeSet();
                IEnumerator allAttributes = attributeSet.GetEnumerator();

                if ( allAttributes.MoveNext() )
                {
                    // found member(s) in this group
                    LdapAttribute attribute =
                        (LdapAttribute)allAttributes.Current;
                    String attributeName = attribute.Name;

                    IEnumerator allValues = attribute.StringValues;

                    if( allValues != null)
                    {
                        while(allValues.MoveNext())
                        {
                            String Value = (String) allValues.Current;
                            Console.WriteLine("            " + attributeName
                                       + " : " + Value);
                        }
                    }
                }
                else
                {
                    // no member(s) found in this group
                    Console.WriteLine("            No objects matched the "
                               + " memberQueryURL filter.\n  ");
                }
            }
        }
        catch( LdapException e )
        {
            Console.WriteLine( "Error: " + e.ToString() );
            status = false;
        }
        return status;
    }
All Usage Examples Of Novell.Directory.Ldap.LdapConnection::Search