473,395 Members | 1,558 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

User Group Membership

I need to find a user's memberOf list, (and all nested groups), very
quickly. My current method is to iterate through the the results of the
the MemberOf property and then do the same to each of those groups.
While complete, this is painfully, painfully, (grow old and die before
it is done), slow.

I have looked at the m_role attribute of the princible object:

WindowsPrincipal MyPrincipal = new WindowsPrincipal(UserIdentity);
MyPrincipal.IsInRole(WindowsBuiltInRole.User);
FieldInfo field = typeof(WindowsPrincipal).GetField("m_roles",
BindingFlags.NonPublic | BindingFlags.Instance);
string[] Roles = (string[])field.GetValue(MyPrincipal);
Write("<hr>Got " + Roles.Length.ToString() + " groups/roles back [string
array]<br>\n");
foreach (string Role in Roles)
{
Write("Group=" + Role + "<br>\n");
}

but this is horribly incomplete and only lists the built in groups,
(Everyone, Domain Users, etc), which is useless to me.

I also tried the TokenGroup properties:

string[] TokenGroups = new string[]
{
"tokenGroups",
"tokenGroupsGlobalAndUniversal",
"tokenGroupsNoGCAcceptable"
};
DirectoryEntry DE = Utility.GetDirectoryEntry(UserDN);
DE.RefreshCache(TokenGroups);

for(int i=0; i<TokenGroups .length; i++)
{
Write("\n<hr>" + TokenGroups[i] + "<br>\n");
PropertyValueCollection tg = DE.Properties[TokenGroups[i]];
foreach (byte[] SID in (Array)tg.Value)
{
Write("SID Name = " + getNameFromSID(SID) + "<br>\n");
}
}

but these are just as incomplete as the m_role list.

This is a common enough problem that I thought there would be lots of
solutions on Google but these 2 methods were all that I could find,
(other than the brutally slow method I am already using).

This code will be calculating complete lists for thousands of users and
my method has way too much overhead. I need the nested groups since our
security model is complex and very deep. Any help would be greatly
appriecaiated.

Thanks

-Cam
Nov 18 '05 #1
3 1609
"cameron" <ca****************@appdepot.com> wrote in message
news:OS**************@TK2MSFTNGP11.phx.gbl...
I need to find a user's memberOf list, (and all nested groups), very
quickly. My current method is to iterate through the the results of the
the MemberOf property and then do the same to each of those groups.
While complete, this is painfully, painfully, (grow old and die before
it is done), slow.


You might want to reconsider your reasons for wanting to do this. What are
you going to do with that list once you get it? And how much do you care
that some of the groups may change their group membership, perhaps even
while you're recursively enumerating?
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #2
It is a web application. The list is used to control the display of the
page since each group can potentially change the layout of the window.
The list is calculated and cached and used until one of its
dependencies, (the groups), are changed at which time it is recalculated.

I can not really use the 'IsInRole' stuff since I do not know the groups
in advance, (user defined groups so they are completely aribarily named
and configured).

-Cam

John Saunders wrote:
"cameron" <ca****************@appdepot.com> wrote in message
news:OS**************@TK2MSFTNGP11.phx.gbl...
I need to find a user's memberOf list, (and all nested groups), very
quickly. My current method is to iterate through the the results of the
the MemberOf property and then do the same to each of those groups.
While complete, this is painfully, painfully, (grow old and die before
it is done), slow.

You might want to reconsider your reasons for wanting to do this. What are
you going to do with that list once you get it? And how much do you care
that some of the groups may change their group membership, perhaps even
while you're recursively enumerating?

Nov 18 '05 #3
"cameron" <ca****************@appdepot.com> wrote in message
news:es**************@TK2MSFTNGP12.phx.gbl...
It is a web application. The list is used to control the display of the
page since each group can potentially change the layout of the window.
The list is calculated and cached and used until one of its
dependencies, (the groups), are changed at which time it is recalculated.

I can not really use the 'IsInRole' stuff since I do not know the groups
in advance, (user defined groups so they are completely aribarily named
and configured).


When a group changes the layout of the window, do you know the name of the
group? If so, you can use IsInRole.
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Brian Loesgen | last post by:
The next San Diego .Net User Group meeting is Tuesday, November 25, 2003 at the Scripps Ranch Library. Scripps Ranch Library 10301 Scripps Lake Drive San Diego, CA 92131-1026 Please join us...
9
by: Terry E Dow | last post by:
Howdy, I am having trouble with the objectCategory=group member.Count attribute. I get one of three counts, a number between 1-999, no member (does not contain member property), or 0. Using...
3
by: mrwoopey | last post by:
Hi, I am using the example "Authenticate against the Active Directory by Using Forms Authentication and Visual Basic .NET": http://support.microsoft.com/default.aspx?scid=KB;EN-US;326340 ...
0
by: clintonG | last post by:
I applied aspnet_regsql to SQL2K which was working fine throughout Beta 2 development. After installing Visual Studio and SQL Express RTM my application has blown up. Logging in to the application...
1
by: VB Programmer | last post by:
I am using personalization/profile to store info for the user that is not contained in the aspnet_Users or aspnet_Membership tables. This info includes, firstname, lastname, and phonenumber. ...
17
by: TC | last post by:
In the past I always regarded user/group security as fairly tight. It is tricky to implement, but once implemented properly, it can't be cracked except through a dedicated effort. Recently,...
3
by: Ryan | last post by:
I am going to create an asp site that allows the users to fill out application information. Their personal information will be stored server side in a SQL 2005 database and they can come back to...
4
by: Scott M. | last post by:
When profile data is stored in ASP .NET, where is the user data persisted? For how long is it persisted: is it session persisted or permanent (like a cookie)?
4
by: Brett | last post by:
I have an ASP.NET 2.0 application that uses Forms Authentication. The startup page contains just a login control, and the site works well on an IIS 6 web server. I am now setting the site up on...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.