SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I try to write a procedure, which find out is the user logged or not not loged in the service. I write a code. But it sometimes giving me a true or false if not a person shown. Sometimes it gives me true or false. Please help me what I'm doing wrong. Here is my code:

   public bool sprawdzanieUserow()
        SPWeb witryna = SPContext.Current.Web;
        SPUserCollection usersAll = witryna.SiteUsers;
        foreach (SPUser oUserPrivilages usersAll)
            if (oUserPrivilages.Name == "Jan Kowalski" || oUserPrivilages.Name == "Wojciech Kowalczyk")
                return true;
        return false;
    } // Koniec sprawdzania userów
share|improve this question
I get ready with this: ` public bool sprawdzanieUserow() { SPWeb site = SPContext.Current.Web; int managerGroup = site.Groups["Właściciele witryny Main"].ID; if (site.IsCurrentUserMemberOfGroup(managerGroup)) { return true; } return false; }` – Grzegorz Z Dec 18 '12 at 14:17
The code from your comment will return true, if current user is in the managerGroup. From the question, I thought you wanted to know if Jan Kowalski or Wojciech Kowalczyk are browsing the site or not. So, which one is it? – Norbert Dec 18 '12 at 14:51
It's whot I needed, but Cant describe it in english – Grzegorz Z Dec 21 '12 at 14:56

Your Answer


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

Browse other questions tagged or ask your own question.