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

Add() public method

Asynchronously adds an entry to the directory.
LdapException A general exception which includes an error /// message and an Ldap error code. ///
public Add ( LdapEntry entry, LdapResponseQueue queue ) : LdapResponseQueue
entry LdapEntry LdapEntry object specifying the distinguished /// name and attributes of the new entry. /// ///
queue LdapResponseQueue Handler for messages returned from a server in /// response to this request. If it is null, a /// queue object is created internally. /// ///
return LdapResponseQueue
        public virtual LdapResponseQueue Add(LdapEntry entry, LdapResponseQueue queue)
        {
            return Add(entry, queue, defSearchCons);
        }

Same methods

LdapConnection::Add ( LdapEntry entry, LdapResponseQueue queue, LdapConstraints cons ) : LdapResponseQueue
LdapConnection::Add ( LdapEntry entry ) : void
LdapConnection::Add ( LdapEntry entry, LdapConstraints cons ) : void

Usage Example

示例#1
0
        static void Main(string[] args)
        {
            if ( args.Length != 5)
            {
            Console.WriteLine("Usage:   mono AddEntry <host name> <ldap port>  <login dn>" + " <password> <container>");
            Console.WriteLine("Example: mono AddEntry Acme.com 389"  + " \"cn=admin,o=Acme\"" + " secret \"ou=sales,o=Acme\"");
            return;
            }

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

            try
            {
            LdapAttributeSet attributeSet = new LdapAttributeSet();
            attributeSet.Add(	new LdapAttribute(
                                "objectclass", "inetOrgPerson"));
                                attributeSet.Add( new LdapAttribute("cn",
                                new string[]{"James Smith", "Jim Smith", "Jimmy Smith"}));
            attributeSet.Add(	new LdapAttribute("givenname",
                                 "James"));
            attributeSet.Add(	new LdapAttribute("sn", "Smith"));
            attributeSet.Add(	new LdapAttribute("telephonenumber","1 801 555 1212"));
            attributeSet.Add(	new LdapAttribute("mail", "*****@*****.**"));
            attributeSet.Add(	new LdapAttribute("userpassword","newpassword"));

            string  dn  = "cn=KSmith," + containerName;
            LdapEntry newEntry = new LdapEntry( dn, attributeSet );
            LdapConnection conn= new LdapConnection();
            Console.WriteLine("Connecting to:" + ldapHost);
            conn.Connect(ldapHost,ldapPort);
            conn.Bind(loginDN,password);
            conn.Add( newEntry );
            Console.WriteLine("Entry:" + dn + "  Added Successfully");
            conn.Disconnect();
            }
            catch(LdapException e)
            {
            Console.WriteLine("Error:" + e.LdapErrorMessage);
            return;
            }
            catch(Exception e)
            {
            Console.WriteLine("Error:" + e.Message);
            return;
            }
        }
All Usage Examples Of Novell.Directory.Ldap.LdapConnection::Add