Showing posts with label Sharepoint. Show all posts
Showing posts with label Sharepoint. Show all posts

Thursday, July 14, 2011

How to get total number of users logged in a day?

There is no direct way of retrieving this information. You have to solution out to get this data. In this article, I have outlined what needs to be done in order to get this data.

Step 1:
- Create a basic delegate control and add it to your MasterPage. In the delegate control, all you do is write code like this to update the OOB SharePoint list that manages all users who have logged into the site. This list can be accessed from this URL

http:/Your Server/_catalogs/users/simple.aspx

========================================Code=========================================================

//You have to run this with elevated privilidges as the user would not have access

//to this list. The list can only be accessed by Admin.

SPSecurity.RunWithElevatedPrivileges(delegate()

{

try

{

using (SPSite oSiteCollection = new SPSite(SPContext.Current.Site.ID))

{

using (SPWeb oWeb = oSiteCollection.RootWeb)

{

oWeb.AllowUnsafeUpdates = true;

SPList myUserList = oWeb.SiteUserInfoList;

SPListItem myUserItem = myUserList.Items.GetItemById(myLoggedInUser.ID);

myUserItem["Name"] = myUser.FirstName + " " + myUser.LastName;

myUserItem["Work e-mail"] = myUser.EmailAddress;

myUserItem.Update();

}

}

}

catch (Exception e1)

{

SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory("External", TraceSeverity.Unexpected, EventSeverity.Error), TraceSeverity.Unexpected, "SecurityWebPart.AddPersonalDetailsToSite-" + e1.Message, "");

}

});

========================================Code=========================================================

This code really does not do much, you can even just put the update statement. When you add this code, it will put the time stamp when the user last logged onto your site.

Step 2
Then, write a timer job to extract daily logged user information from the above list and store it in another List. The reason you have to do this is so as to maintain the history.

Step 3
Finally, you can present your information in a webpart or directly from this list.

Wednesday, June 15, 2011

Everything you need to know about Document Ids in SharePoint 2010

Document Id is a cool feature in SharePoint 2010. It has many uses that you you would not consider it using initally. However, with time you will find that it is a simple out of the box feature that has power. When you turn this feature on, SP will add a new column "Document Id" to all document libraries. SP will also display a new link [Document ID Settings] in Site Collection Admin section, which will be used to configure this feature. SP randomly generates a set of characters that it will use to prefix every document ID. You can change the document ID's initial characters.

Document Ids are not preseved when moving the document library from 1 enviornment to another.

If you don't like the algorithm associated with generating document id, you can extend the functionality using Visual Studio.

If you closely look at the URL associated with the Document Id, it is actually referring to an asp page and passing the ID as QS paramter. The page[DocIdRedir] is basically a router that is accepting an ID and redirecting to the location of the document.
http://sp2010dev01/_layouts/DocIdRedir.aspx?ID=RTTT-1-4


When you copy this document to another location, SP creates a new document id.

How do you turn on this feature?
You can turn on this feature by activating a Document Id Service via Site collection feature page. You could also do it via PowerShell.

What happens when you trun on this feature?
Document ID assignment job gets scheduled to be run 8 hrs from the moment the service has been turned on.

Monday, May 2, 2011

SharePoint 2010 Application Development Certification

This morning I took this exam hoping that there would be atleast a few questions on claims based authentication. Unfortunately, there were no question on this topic.

I faintly remember that in SharePoint 2010 configuration exam they do briefly cover claims based authentication in respect of extending a web application/authentication providers.

The exam that I passed was 70-573. It was a pretty interesting exam as it covered a very large aspect of SharePoint Development. The questions were mainly on these topics:
- Site and Web
- BCS
- REST (1-2)
- Logging (2-3)
- Ribbon (6-7)
- Security i.e.RunWithElevatedPrivilidges (2)
- QuickLaunch (2)
- LINQ (1)
- Query (2-3)

Sunday, May 1, 2011

Step 1: Claims Based Authentication (Software Required & Hardware)

In my setup, I had the following softwares in order to get the claims based authentication to work. You can install all the softwares on the same VM/HyperV it would not really matter. Typically most people have the list of the software below, but not have Microsoft Identity Framework. This is a free software from Microsoft that is required in order to set up STS.

- Microsoft Identity Framework 3.5 (Note: Not 4.0)
- SharePoint 2010
- Visual Studio 2010

Hardware
In my setup at the client, here is how my VM machine evolved over a period of 6 weeks:
- 1 VM - 2 GB Ram and 1 Processor (week 1) with SQL Express
- 1 VM - 4 GB Ram and 1 Processor (week 2) with SQL Express
- 2 VM - 4 GB Ram and 1 Processor and 2 GB Ram and 1 Processor (Full SQL)
- 2 VM - 4 GB Ram and 2 Processor and 2 GB Ram and 1 Processor (Full SQL)
- 2 VM - 8 GB Ram and 2 Processor and 4 GB Ram and 1 Processor (Full SQL)
- 2 VM - 8 GB Ram and 2 Processor and 8 GB Ram and 2 Processor (Full SQL)

SharePoint worked even in my week 1, but it was very slow. If you are going to be debugging the code, then it is better to start with 8GB Ram and 2 processor. If you have anything less then it takes approximately 60-70 seconds to cause the processor to break at your break point and another 20 seconds to just stop it. In the last week, we added more RAM and Processor to other VM because I added another developer. We used the same SQL Server box for the new developer too.

Step 0: Claims Based Authentication

On the internet, you can find half a dozen walkthroughs on claims based authentication, but they all don't work accordingly. Some of them have some issue when you deploy the code.

In the next several blog posts, I will step through the process of registering a STS and Claims Provider and then setting up a Web App in SharePoint that is integrated with your STS.

Saturday, April 30, 2011

Integration with Oracle

If your login information is stored in Oracle you can integrate it with Sharepoint.

Essentially you have to create a website (Secured token service) that a user will be redirected to when they go to Sharepoint. This web site wil authenticate the user and then redirect the user back to Sharepoint and then user can login to Sharepoint.

Over the next several weeks I will go through the process of creating this integration. I recently completed this integration for a large client.