[Mono-dev] System.DirectoryServices from linux

nemus at grayhatlabs.com nemus at grayhatlabs.com
Thu May 5 15:20:43 EDT 2011


Hello I am trying to create a mono program that can control an active
directory from a Linux server System.DirectoryServices doesn't seam to
work the same way as it does on a windows client.

I can get the following code to run on a windows 7 and xp box but I cannot
get it to work on ubuntu 10.10 or 11.04

Anyhelp on this would be great thanks.


    gmcs /pkg:dotnet /r:System.DirectoryServices Main.cs
    Main.cs(4,32): error CS0234: The type or namespace name
`ActiveDirectory' does not exist in the namespace
`System.DirectoryServices'. Are you missing an assembly reference?
    Main.cs(4,32): error CS0234: The type or namespace name
`ActiveDirectory' does not exist in the namespace
`System.DirectoryServices'. Are you missing an assembly reference?
    Compilation failed: 2 error(s), 0 warnings


    mono -V
    Mono JIT compiler version 2.6.7 (Debian 2.6.7-5ubuntu3)
    Copyright (C) 2002-2010 Novell, Inc and Contributors.
www.mono-project.com
            TLS:           __thread
            GC:            Included Boehm (with typed GC and Parallel Mark)
            SIGSEGV:       altstack
            Notifications: epoll
            Architecture:  amd64
            Disabled:      none



    cat /usr/lib/pkgconfig/dotnet.pc

    Name: Standard libraries in a .NET setup
    Description: References all the standard .NET libraries for compilation
    Version: 2.6.7
    Libs: -r:Accessibility.dll -r:cscompmgd.dll -r:Microsoft.JScript.dll
-r:Microsoft.VisualC.dll -r:Microsoft.Vsa.dll
-r:System.Configuration.Install.dll -r:System.Data.dll
-r:System.Data.OracleClient.dll -r:System.Design.dll
-r:System.DirectoryServices.dll -r:System.dll
-r:System.Drawing.Design.dll -r:System.Drawing.dll
-r:System.EnterpriseServices.dll -r:System.Management.dll
-r:System.Messaging.dll -r:System.Runtime.Remoting.dll
-r:System.Runtime.Serialization.Formatters.Soap.dll
-r:System.Security.dll -r:System.ServiceProcess.dll -r:System.Web.dll
-r:System.Web.Services.dll -r:System.Windows.Forms.dll
-r:System.Xml.dll

    I can compile the code on a windows machine and it works fine when I
scp it to ubuntu 11.04
    and run  I get this error:

    mono Test.exe
    hello world

    Unhandled Exception: LdapException: (32) No Such Object
    LdapException: Server Message: 0000208D: NameErr: DSID-031001E5,
problem 2001 (NO_OBJECT), data 0, best match of:
            ''
    I get htis problem mono Test.exe
    hello world

    Unhandled Exception: LdapException: (32) No Such Object
    LdapException: Server Message: 0000208D: NameErr: DSID-031001E5,
problem 2001 (NO_OBJECT), data 0, best match of:
            ''
    code

    Console.WriteLine("hello world");
    DirectoryEntry entry = new DirectoryEntry("LDAP://xxxx",
"xxx at yyyy.com", "bestpasswordever");

    string userName = ExtractUserName("Jshmo");

    DirectorySearcher search2 = new DirectorySearcher(entry);

    search2.Filter = String.Format("(SAMAccountName={0})", userName);
    search2.PropertiesToLoad.Add("cn");

    SearchResult result = search2.FindOne();
    Console.WriteLine(result.Path);




More information about the Mono-devel-list mailing list