SharePoint 2010 user login check

Check if a user is logged in

If you want to know if a user is logged in or not you can check it with the CurrentUser object from the SPWeb.

Here’s how you do it in an example:

using Microsoft.SharePoint;
 
SPWeb web = SPContext.Current.Web;
if (web.CurrentUser == null) 
    //hide something
else
    //don’t hide something
Remember sometimes the using Microsoft.SharePoint isn’t always default given, if not add it.

Advertisements
This entry was posted in Geen categorie. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s