LDAP Client.Net

Client.AddNewEntry Method 

Add a new entry to the directory, using the specified attributes and values to initialize it.

[Visual Basic]
Public Function AddNewEntry( _ 
   ByVal dn As String, _ 
   ByVal attributes As NameValueCollection _ 
) As Entry
[C#]
public Entry AddNewEntry(
   string dn,
   NameValueCollection attributes
);
[C++]
public: Entry* AddNewEntry(
   String* dn,
   NameValueCollection* attributes
);
[JScript]
public function AddNewEntry(
   String dn,
   NameValueCollection attributes
): Entry;

Parameters

dn
Distinguished name of the new entry.
attributes
Attributes of the new entry represented by a collection of name-value mappings.

Return Value

The new entry.

Example

[C#]
using System;
using System.Collections.Specialized;
using LdapServices.Ldap;

namespace LDAPSampleCodeConsole
{
class SampleApp
{
static void Main(string[] args)
{
Client client = new Client();

// Connect to the directory
client.Connect("directory.yourCompany.ca");

// Create a name value collection of the attributes you want in the entry
NameValueCollection nvc = new NameValueCollection();
nvc.Add("uid", "Jane" );
nvc.Add("cn", "Jane" );
nvc.Add("givenName", "Jane" );
nvc.Add("sn", "Johnston" );
nvc.Add("objectClass", "person");
nvc.Add("objectClass", "organizationalPerson" );
nvc.Add("objectClass", "top" );
nvc.Add("objectClass", "inetOrgPerson" );

// Add the new entry
client.AddNewEntry("cn=Jane,ou=people,o=yourCompany,c=ca", nvc);

client.Disconnect();
}
}
}

See Also

Client Class | LdapServices.Ldap Namespace