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

Read() public method

Synchronously reads the entry for the specified distinguished name (DN), using the specified constraints, and retrieves only the specified attributes from the entry.
LdapException if the object was not found ///
public Read ( System dn, System attrs, LdapSearchConstraints cons ) : LdapEntry
dn System The distinguished name of the entry to retrieve. /// ///
attrs System The names of the attributes to retrieve. /// ///
cons LdapSearchConstraints The constraints specific to the operation. /// ///
return LdapEntry
        public virtual LdapEntry Read(System.String dn, System.String[] attrs, LdapSearchConstraints cons)
        {
            LdapSearchResults sr = Search(dn, SCOPE_BASE, null, attrs, false, cons);

            LdapEntry ret = null;
            if (sr.hasMore())
            {
                ret = sr.next();
                if (sr.hasMore())
                {
                    // "Read response is ambiguous, multiple entries returned"
                    throw new LdapLocalException(ExceptionMessages.READ_MULTIPLE, LdapException.AMBIGUOUS_RESPONSE);
                }
            }
            return ret;
        }

Same methods

LdapConnection::Read ( LdapUrl toGet ) : LdapEntry
LdapConnection::Read ( LdapUrl toGet, LdapSearchConstraints cons ) : LdapEntry
LdapConnection::Read ( System dn ) : LdapEntry
LdapConnection::Read ( System dn, LdapSearchConstraints cons ) : LdapEntry
LdapConnection::Read ( System dn, System attrs ) : LdapEntry

Usage Example

Example #1
0
    // findACLValues() reads the entry to get it's ACL values
    public static void findACLValues(LdapConnection lc, String entry)
    {
        String[] returnAttrs = { "acl" };
        String attributeName;
        IEnumerator allValues;
        LdapAttribute attribute;
        LdapAttributeSet attributeSet;

        try
        {
            LdapEntry aclList = lc.Read( entry, returnAttrs );

            // printout entryDN's ACL values
            attributeSet = aclList.getAttributeSet();
            IEnumerator allAttributes = attributeSet.GetEnumerator();

            Console.WriteLine("    =========================================");
            Console.WriteLine("    entryDN's ACL values after modification:");
            Console.WriteLine("    =========================================");
            if (allAttributes.MoveNext())
            {
                attribute = (LdapAttribute)allAttributes.Current;
                attributeName = attribute.Name;
                allValues = attribute.StringValues;
                while(allValues.MoveNext())
                {
                    PrintACLValue((String)allValues.Current);
                }
            }
        }
        catch( LdapException e )
        {
            Console.WriteLine( "Error: ModdifyACL, " + e.ToString() );
            Environment.Exit(1);
        }
    }
All Usage Examples Of Novell.Directory.Ldap.LdapConnection::Read