Nigel Benns a �crit :
I've had quite a bit of success working with some test programs and
OpenLdap, but the only thing I cannot do is write to the directory store.

DirectoryEntry.CommitChanges() runs and exits ok, but doesn't seem to
really do anything. Then next time I run it, or read the directory in GQ
the entry is still exactly the same.

CommitChanges() works fine for me from mono-1.0.0 to mono-1.1.1, and I can write to OpenLDAP (2.0 and 2.1). Are you sure there is no exception ? Maybe your binding is wrong, or you do not respect the LDAP schema...

Attached is an example code of mine that creates a user entry. You could
also send me your code so I can test it.

Right now I'm using Mono-1.0 with Linux Mandrake 10.1 (actually Cooker,
I'm going to redo my Laptop with 10.1 PowerPack now that its out)

I use Mandrake 10.0 and Debian Sarge.

--
Arnaud Bienvenu
Makina Corpus

using System;
using System.DirectoryServices;

public class Client
{
  public static void Main()
  {
    try
    {
      DirectoryEntry DirEntry = new DirectoryEntry("LDAP://ldap.makina-corpus.org/ou=People,dc=mcjam,dc=org";, "cn=admin,dc=makinacorpus,dc=org", "*********");
      DirectoryEntries people = DirEntry.Children;

      DirectoryEntry newentry = people.Add("uid=essai", "top");
      newentry.Properties["objectClass"].Add("posixAccount");
      newentry.Properties["objectClass"].Add("shadowAccount");
      newentry.Properties["objectClass"].Add("person");
      newentry.Properties["objectClass"].Add("organizationalPerson");
      newentry.Properties["objectClass"].Add("inetOrgPerson");

      newentry.Properties["userid"].Value = "essai";
      newentry.Properties["cn"].Value = "Ceci est un essai";
      newentry.Properties["uidNumber"].Value = "65534";
      newentry.Properties["gidNumber"].Value = "65534";
      newentry.Properties["homeDirectory"].Value = "/home/users/essai";
      newentry.Properties["sn"].Value = "Essai";
      newentry.CommitChanges();
    }
    catch (Exception ex)
    {
      Console.WriteLine("Exception : " + ex.Message);
    }
  }
}

Reply via email to