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