Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

So I have a list of managers in my SharePoint site, and I am able to get the current user by using a web service and storing their name into a control. Is it possible to compare this name to everyone in that list/group to check if they are a manager so that the form can switch views to the manager section?

Right now I created a drown down control which pulls in values from the list and sets the default value to the contact. But it can only store and compare one contact. How could I have it compare the current user against everyone in the list?

Thank you in advance.

share|improve this question

1 Answer 1

You can use a SharePoint group instead, put your managers in it, and then use something like this to see if the current user is a member:

    bool IsMember(string groupName)
    {
        try
        {
            return SPContext.Current.Web.SiteGroups[groupName].ContainsCurrentUser;
        }
        catch
        {
            return false;
        }
    }
share|improve this answer
    
nice work, is there a way to do it without code? –  tehman Oct 12 '11 at 13:35
    
If by "no code" you mean no compiled code, and you are willing to roll up your sleeves an write some javascript, it can be done. Here's an msdn article that explains working with users and groups in client side script: msdn.microsoft.com/en-us/library/hh185012.aspx –  Jon Lester Oct 13 '11 at 3:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.