System.Directoryservices won't appease me...

I was playing around with another  user control yesterday that would allow me to show people who is inside an AD Group.  Unfortunately, in the object model (as far as I can tell) there is one function "IsDomainGroup" that can even help out.  So that inevitably brought me to use this AD Wrapper that someone created in my company.  It will display the group users on a windows app on the server or on an asp .net application on the server in the c:/program files/common files/microsoft shared/web server extensions/12/templates/layouts.  When I try to use it off the server it gives me a nasty error message that I do not have permissions to use System.DirectoryServices.  So far I have done some googling and I saw an article about how I should change the web.config to full control.  This is a no go for security reasons I am not moving from wss_medium.  I find these answers unacceptable and I am going to look around for another answer.  There are always ten answers to one problem and fifty other steps in between that vary on the process you take.  Just remember that when you are working on a problem that is incredibly hard to solve.  There is never just one answer.

Print | posted on Saturday, April 12, 2008 10:30 AM

Feedback

# re: System.Directoryservices won't appease me...

Left by J at 4/13/2008 11:32 AM
Gravatar How about SPSecurity.RunWithElevatedPrivileges?

# re: System.Directoryservices won't appease me...

Left by MOSSLover at 4/13/2008 11:40 AM
Gravatar I already put that in the code...I should have mentioned you need to add that piece of code and elevate the web.config.

# re: System.Directoryservices won't appease me...

Left by AlphaAlien at 4/15/2008 1:43 PM
Gravatar Here's some code I did awhile ago to check whether a user was an administrator, this could be modified to check for whether they're in any security group or return an array of groups they belong too.

private void disable_controls()
{
//get identity and groups user belongs to for admin check
System.Security.Principal.WindowsIdentity identity = System.Security.Principal.WindowsIdentity.GetCurrent();
System.Security.Principal.WindowsPrincipal principal = new System.Security.Principal.WindowsPrincipal(identity);

string[] adminGrps = new string[] { "Administrators", "Domain Admins" };
foreach (string admin in adminGrps)
{
bool value = principal.IsInRole(domainName + "\\" + admin);

That should get you started

# re: System.Directoryservices won't appease me...

Left by MOSSLover at 4/15/2008 4:49 PM
Gravatar I think that System.Security.Principal can be used to get the users within a group too. Thanks for posting that information. You rock.

Your comment:





 
 

Copyright © MOSSLover

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski