Delete() public method

Asynchronously deletes the entry with the specified distinguished name from the directory and returns the results to the specified queue. Note: A Delete operation will not remove an entry that contains subordinate entries, nor will it dereference alias entries.
LdapException A general exception which includes an error /// message and an Ldap error code. /// ///
public Delete ( System dn, LdapResponseQueue queue ) : LdapResponseQueue
dn System The distinguished name of the entry to modify. /// ///
queue LdapResponseQueue The queue for messages returned from a server in /// response to this request. If it is null, a /// queue object is created internally. /// ///
return LdapResponseQueue
Example #1
0
        static void Main(string[] args)
        {
            if ( args.Length != 5)
            {
            Console.WriteLine("Usage:   mono DelEntry <host name> <ldap port>  <login dn>" + " <password> <entry dn>");
            Console.WriteLine("Example: mono DelEntry Acme.com 389"  + " \"cn=admin,o=Acme\"" + " secret \"cn=cjhones,o=acme\"");
            return;
            }

            string ldapHost = args[0];
            int ldapPort = System.Convert.ToInt32(args[1]);
            String loginDN  = args[2];
            String password = args[3];
            String dn = args[4];

            try
            {
            Console.WriteLine("Connecting to:" + ldapHost);
            LdapConnection conn= new LdapConnection();
            conn.Connect(ldapHost,ldapPort);
            conn.Bind(loginDN,password);
            conn.Delete(dn);
            Console.WriteLine(" Entry: " +  dn + " Deleted Successfully");
            conn.Disconnect();
            }
            catch(LdapException e)
            {
            Console.WriteLine("Error:" + e.LdapErrorMessage);
            return;
            }
            catch(Exception e)
            {
            Console.WriteLine("Error:" + e.Message);
            return;
            }
        }
Example #2
0
    // delete the  dynamic group entry
    public static bool deleteDynamicGroupEntry( LdapConnection lc,
        String deleteDN)
    {
        bool status = true;

        try
        {
            // Deletes the entry from the directory
            lc.Delete( deleteDN );
            Console.WriteLine("\tEntry: " + deleteDN + " was deleted." );
        }
        catch( LdapException e )
        {
            Console.WriteLine( "\t\tFailed to remove dynamic group entry." );
            Console.WriteLine( "Error: " + e.ToString() );
            status = false;
        }
        return status;
    }