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

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
1  
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
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.