Hello All
I'm trying this to filter group users bu tI keep getting an unspecified
error when invoking FindOne method.
Any help is greatly appreciated.
public static DirectoryEntry GetDirectoryRoot()
{
return new DirectoryEntry("LDAP://RootDSE");
}
public static string DefaultNamingCtx
{
get{
string defCtx=null;
using(DirectoryEntry rootDe = GetDirectoryRoot())
{
defCtx = rootDe.Properties["defaultNamingContext"][0].ToString();
}
return defCtx;
}
}
public static void GetGroupUsers(string groupName, ADSet dSet)
{
DirectorySearcher deSearch = new DirectorySearcher();
deSearch.SearchRoot = new DirectoryEntry(DefaultNamingCtx);
deSearch.Filter = string.Format("(&(objectClass=group)(cn={0}))",
groupName);
try
{
SearchResult result = deSearch.FindOne(); //***This keeps failing ***
}
catch(COMException ex)
{}