[Mono-dev] System.DirectoryServices error

Daniel Peñalba dpenalba at codicesoftware.com
Tue Jan 31 11:49:06 EST 2006


Hello. I'm working with a LDAP server and I want to get a list of users. I have a ActiveDirectory Server in 192.168.1.3

I tried with the next code, It works on Windows systems.

public static void GetUsers() 
        {
            ArrayList result = new ArrayList();
            string rootPath = "LDAP://192.168.1.3";
            try
            {
                DirectoryEntry root = new DirectoryEntry(rootPath);
                DirectorySearcher searcher = new DirectorySearcher(root);
                //The the computers are considered users by the active directory
                searcher.Filter = "(&(!(objectClass=computer))(objectClass=user))";
                SearchResultCollection allResults = searcher.FindAll();
                foreach (SearchResult item in allResults) 
                {
                    if ( item != null )
                    {
                        ResultPropertyCollection properties = item.Properties;
                        Object o = properties["name"][0];
                        Console.WriteLine(o);
                    }
                }    
                
            }
            catch(Exception e) 
            {
                throw new Exception("There is no active directory in this server: " + e);
            }
        }

But on Linux systems (with mono) doesn't work.

Somebody can tell me how fix this.

The error obtained is the next:

Unhandled Exception: System.Exception: Error conecting with the LDAP server: LdapException: (32) No Such Object LdapException: Server Message: 000208D: NameErr: DSID-03100193, problem 2001 (NO_OBJECT), data 0, best match of:   ' '
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060131/f8ccecff/attachment.html 


More information about the Mono-devel-list mailing list