473,508 Members | 2,079 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1615
"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
1970
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
10808
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
16423
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
1669
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
2302
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
2655
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
3179
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
2488
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
3776
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
7226
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
7125
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
7328
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,...
1
7049
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...
0
7499
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5055
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3199
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1561
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
767
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.