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

Search() public static method

Synchronously performs the search specified by the Ldap URL, returning an enumerable LdapSearchResults object.
LdapException A general exception which includes an error /// message and an Ldap error code. ///
public static Search ( LdapUrl toGet ) : LdapSearchResults
toGet LdapUrl The Ldap URL specifying the entry to read. /// ///
return LdapSearchResults
        public static LdapSearchResults Search(LdapUrl toGet)
        {
            // Get a clone of default search constraints, method alters batchSize
            return Search(toGet, null);
        }

Same methods

LdapConnection::Search ( System base_Renamed, int scope, System filter, System attrs, bool typesOnly, LdapSearchQueue queue ) : LdapSearchQueue
LdapConnection::Search ( System base_Renamed, int scope, System filter, System attrs, bool typesOnly, LdapSearchQueue queue, LdapSearchConstraints cons ) : LdapSearchQueue
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