Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 2nd, 2004, 04:53 AM
Authorized User
 
Join Date: Jun 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Forms Authentication - Groups

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);
}
--------------------------------

 
Old June 2nd, 2004, 09:02 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Everyone who is a validated user is a member of domain users. I don't belive it's reported- just like it's not reported that the user is a memeber of the "Everyone" group.

Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee





Similar Threads
Thread Thread Starter Forum Replies Last Post
Forms Authentication thetway Classic ASP Basics 1 August 18th, 2005 05:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.