Hi everyone!
I am using the article
http://msdn.microsoft.com/library/en...asp?frame=true to implement authentication with the active directory. Everything works fine - the user is authenticated but when it comes to retrieving the groups that the user is in, the group "Domain Users" is never returned. The other groups that the user is part of are brought back. The group names are printed onto the form separated using |. The member of property is used to retrieve the groups. When i look at the users profile in the active directory the groups that the user is part of are in the member of tab. Domain Users is here and so are all the other groups for that user but all groups are printed on the screen except for domain users. Sorry if something like this has been posted already but when i searched for it i couldnt fins anything similar.
This is the procedure that is used to get the groups that the user currently logged in is part of:
public string GetGroups()
{
DirectorySearcher search = new DirectorySearcher(_path);
search.Filter = "(cn=" + _filterAttribute + ")";
search.PropertiesToLoad.Add("memberOf");
StringBuilder groupNames = new StringBuilder();
try
{
SearchResult result = search.FindOne();
int propertyCount = result.Properties["memberOf"].Count;
groupNames.Append("propertyCount: "+propertyCount+"<BR>");
String dn;
int equalsIndex, commaIndex;
for( int propertyCounter = 0; propertyCounter < propertyCount;
propertyCounter++)
{
dn = (String)result.Properties["memberOf"][propertyCounter];
equalsIndex = dn.IndexOf("=", 1);
commaIndex = dn.IndexOf(",", 1);
if (-1 == equalsIndex)
{
return null;
}
groupNames.Append(dn.Substring((equalsIndex + 1),
(commaIndex - equalsIndex) - 1)+"<BR>");
groupNames.Append("|");
}
}
catch(Exception ex)
{
throw new Exception("Error obtaining group names. " +
ex.Message);
}
--------------------------------