[Mono-dev] Active Directory issues
Ron Davis
r.ronald.davis at gmail.com
Thu Aug 12 22:23:09 EDT 2010
I am currently porting an application to Mono that requires Active Directory
integration, but can't seem to get the same code base to run under .NET 3.5
and Mono. I am using Mono 2.6.4, but I've also tried a build of 2.6.7. For
example, if I want to fetch the defaultNamingContext, I can do it in .NET
with:
using (DirectoryEntry de = new DirectoryEntry())
{
de.AuthenticationType = AuthenticationTypes.Anonymous;
de.Path = "LDAP://192.168.1.2/rootDSE";
_defaultNamingContext =
de.Properties["defaultNamingContext"][0].ToString();
}
However, under Mono, this fails with an LdapException
Cause: LDAP Error Message: 0000208F: NameErr: DSID-031001F7, problem 2006
(BAD_NAME), data 8350, best match of:'rootDSE'
Error Message: Invalid DN Syntax
ResultCode: 34
Instead, I can get it working under Mono with:
using (DirectoryEntry de = new DirectoryEntry())
{
de.AuthenticationType = AuthenticationTypes.Anonymous;
de.Path = "LDAP://192.168.1.2";
using (DirectorySearcher deSearch = new DirectorySearcher())
{
deSearch.SearchRoot = de;
deSearch.SearchScope = System.DirectoryServices.SearchScope.Base;
deSearch.PropertiesToLoad.Add("defaultNamingContext");
using (SearchResultCollection src = deSearch.FindAll())
{
foreach (SearchResult sr in src)
{
ResultPropertyValueCollection rpvc =
sr.Properties["defaultNamingContext"];
if (rpvc != null)
_defaultNamingContext = rpvc[0].ToString();
}
}
}
but this fails in .NET with System.Runtime.InteropServices.COMException,
"The specified directory service attribute or value does not exist.
Is there an easy way around this?
Should I just abandon System.DirectoryServices and instead just use
Novell.Directory.Ldap?
The AD server is running Windows 2008 R2.
Thanks!
-Ron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20100812/7c31d921/attachment-0001.html
More information about the Mono-devel-list
mailing list