Rename() public method

Asynchronously renames an existing entry in the directory, possibly repositioning the entry in the directory.
LdapException A general exception which includes an error /// message and an Ldap error code. ///
public Rename ( System dn, System newRdn, System newParentdn, bool deleteOldRdn, LdapResponseQueue queue ) : LdapResponseQueue
dn System The current distinguished name of the entry. /// ///
newRdn System The new relative distinguished name for the entry. /// ///
newParentdn System The distinguished name of an existing entry which /// is to be the new parent of the entry. /// ///
deleteOldRdn bool If true, the old name is not retained as an /// attribute value. If false, the old name is /// retained as an attribute value. /// ///
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
Esempio n. 1
0
        static void Main(string[] args)
        {
            if ( args.Length != 7)
            {
            Console.WriteLine("Usage:   mono RenameEntry <host name> <ldap port>  <login dn>" + " <password> <old dn> <new rdn> <parentDN>");
            Console.WriteLine("Example: mono RenameEntry Acme.com 389"  + " \"cn=admin,o=Acme\"" + " secret \"cn=ksmith,o=Acme\"   cn=JamesSmith \"o=Products,o=Acme\"");
            return;
            }

            string ldapHost = args[0];
            int ldapPort = System.Convert.ToInt32(args[1]);
            String loginDN  = args[2];
            String password = args[3];
            String oldDN = args[4];
            String newRDN = args[5];
            String parentDN = args[6];

            try
            {
            Console.WriteLine("Connecting to:" + ldapHost);
            LdapConnection conn= new LdapConnection();
            conn.Connect(ldapHost,ldapPort);
            conn.Bind(loginDN,password);
            conn.Rename(oldDN, newRDN, parentDN, true);
            Console.WriteLine( "Entry " + oldDN + " has been renamed as " + newRDN + "," + parentDN  );
            conn.Disconnect();
            }
            catch(LdapException e)
            {
            Console.WriteLine("Error:" + e.LdapErrorMessage);
            return;
            }
            catch(Exception e)
            {
            Console.WriteLine("Error:" + e.Message);
            return;
            }
        }