2

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.

1 Answer 1

4

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;
        }
    }
2
  • nice work, is there a way to do it without code?
    – tehman
    Commented Oct 12, 2011 at 13:35
  • 1
    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
    Commented Oct 13, 2011 at 3:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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