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

In SharePoint 2010, how would you know if someone has logged in?

I looked at the SDK and with the new User Profiles and Social Data sdk, I wasn't able to find this.

share|improve this question
add comment

4 Answers 4

Very good question. You could enable 'view' audit logging and look for events for a user in the Audit log.

share|improve this answer
add comment

how bout creating your own login form and simply track that ?

Writing a Custom forms login for Sharepoint 2010

share|improve this answer
    
I think this would be the obvious route to take. I was hoping with the new Social Data / UserProfiles SDK that they would have some sort of an event we can subscribe to. Something very fundamental to social data. –  ShareBear Jan 10 '11 at 16:48
add comment

You could use an HTTPModule and track the user yourself.

share|improve this answer
add comment

You could combine a HttpModule with the activity feed infrastructure, to get regular updates in a user's feed of, for example, what page they were looking at.

http://code.msdn.microsoft.com/activityfeedsconsole

public class ActivityFeedHttpModule : IHttpModule {
    public virtual void Init(HttpApplication app) {
        app.EndRequest += new EventHandler(app_EndRequest);
    }
    private void app_EndRequest(object sender, EventArgs e) {
        bool createevent = true; //do some logic here to only log event every 30 mins based on cookie or something
        if(createevent) {   
            SPServiceContext context = SPServiceContext.GetContext(aSite);
            UserProfileManager m_UPM = new UserProfileManager(context);
            string username = Environment.UserDomainName + "\\" + Environment.UserName;
            UserProfile userProfile = m_UPM.GetUserProfile(username);       
            ActivityEvent activityEvent = ActivityEvent.CreateActivityEvent(m_ActivityManager, activityType.ActivityTypeId, owner, publisher);
            activityEvent.Name = activityType.ActivityTypeName;
            activityEvent.ItemPrivacy = (int)Privacy.Public;
            activityEvent.Owner = owner;
            activityEvent.Publisher = publisher; 
            Link link = new Link();
            link.Href = siteUrl;
            link.Name = communityName;
            activityEvent.Link = link;  
            activityEvent.Commit();
        }
    }
}
share|improve this answer
add comment

Your Answer

 
discard

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

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