[Mono-list] DirectoryServices class

Nigel Benns nigel_benns@rogers.com
Fri, 29 Oct 2004 21:00:55 -0400 (EDT)


------=_20041029210055_55139
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

Ok that worked, but I caught an exception of "Error:". Which is odd....

My code doesn't work though...

you specify mono AD Write.exe
ldap://localhost/cn=Manager,ou=People,o=Alexandria description hello

basically the object you want to modify, the attribute to modify and
what to modify it too. The binding and password is in the code

It spits out the entry, changes it in the code, but does not commit.
For the sake of it I set my ACL in slapd.conf to access to * by * write
and it doesn't change anything.

It executes properly and everything... and the code is right off of MSDN
(go figure).

I'm going to try to update mono as well... (if Mandrake has a new
version), I'll get back to you on the status after I do that.

> 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
>

------=_20041029210055_55139
Content-Type: text/x-csharp; name="AD Write.cs"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="AD Write.cs"

using System;
using System.DirectoryServices;

public class ADWrite {
    public static void Main(String[] args) {
        if ( args.Length!=3 ) {
            Console.WriteLine("Usage: " + Environment.GetCommandLineArgs()[0] + " <ad_path> <property> <value>");
            Console.WriteLine ();
            Console.WriteLine ("Press Enter to continue...");
            Console.ReadLine();
            return;
        }

        DirectoryEntry objDirEnt = new DirectoryEntry(args[0],"cn=Manager,ou=People, o=Alexandria", "secret");
        Console.WriteLine("Name            = " + objDirEnt.Name);
        Console.WriteLine("Path            = " + objDirEnt.Path);
        Console.WriteLine("SchemaClassName = " + objDirEnt.SchemaClassName);
        Console.WriteLine(args[1] + " = " + (objDirEnt.Properties[args[1]][0]).ToString());
        Console.WriteLine("... changing to ");
        objDirEnt.Properties[args[1]][0] = args[2];
        objDirEnt.CommitChanges();
        Console.WriteLine(args[1] + " = " + (objDirEnt.Properties[args[1]][0]).ToString());
    }
}
------=_20041029210055_55139--