Friday, December 30, 2011

Upgrading WebParts as Part of Feature Upgrade

Have you ever had an opportunity where you need to add web parts using SP upgrade? Alternatively, you have successfully upgraded, but web parts don't show up in the Web Gallery? This happens as the code gets deployed and you can refer to webpart via code, however it will not show up in the gallery.
When you upgrade a feature, SP simply ignores all the ElementManifests it finds in the Feature.XML file. The other thing you have to realize is that by default provisioning only occurs during feature activation and not during the upgrade. How do you ensure that during the feature upgrade a webpart is successfully provisioned and gets displayed in the WebPart Gallery? Here are the steps you have to follow using the easier declarative method:
Assumptions:
Name of Feature : MyFeature
Web Part Provisioned : MobilePasswordReset
Step 1: In your solution, open MyFeature.Template.XML file, this is the file that will have the name of the feature followed by template.XML.
Step 2: This is how your file will look for most of the cases unless there is some upgrade statements.

Step 3: Need to make a few changes to the above file:
-Add Id of Feature.
-Add Scope
-Upgrade Actions->ApplyElementManifest->ElementManifest

This is how your XML should look as per the image.

Now, when you run the upgrade power shell, the web part will be provisioned. What will happen is that SP will look in this location and it the web part gallery. The other thing to note is that anything you write in customupgradeaction will not help, unless you write code in that event to add webpart to gallery.

Friday, September 2, 2011

How to make a .NET Developer become a good SharePoint Developer?

This morning, in the shower I started thinking how do you transform a .NET Developer into a good SharePoint Developer. I guess a part of the reason why I started thinking in those terms is because I successfully conducted a SharePoint 2010 Developer training at a client recently.
The training was great if you have SharePoint background. If you are a .NET developer the training will provide you lot of information about SharePoint not necessarily enough for you to start developing professional grade applications in SharePoint. I started thinking as to what all is required for a .NET developer to start developing in SharePoint. If you look in the market, there are at least 4 different SharePoint training tracks available (Developer, Power User, Admin, and Branding). Organizations across the globe are spending money to train their employees in one or more SharePoint trainings in order to transform them as .NET developers to SharePoint developers. At the same time, the companies are savvy and they don’t want to spend more money than it is required. There is a lot of pressure on both sides as the expectations are that after the .NET developer goes through some training they are ready for doing SharePoint development. This may be true in an ideal condition, but we are not living in an ideal world so this expectation has to be discounted. In my opinion, you need a mix of 4 training tracks in order to make a good SharePoint developer.

I came from .NET background and I have successfully transformed into the SharePoint World. I have been doing SP for a while now and specifically SharePoint 2010 for over a year now where I have done everything from capacity planning, architecture, development, administration, and training.
There is a thin line between what bare minimum you need to know is and what is too much in SharePoint. In this document, I am going to define at a high level what all you need to know in order to become a decent and then in future a good SharePoint developer. This will be a combination of Administration, Development, and Power User training.
This training is like how you would do a project using one of the agile methodologies. This learning program is continuous and iterative in nature where you build upon what you learnt in Part 1 all the way up to Part 5. I have added part 6 only for very advanced learning.
Part 1:
• First of all developers, need to understand the big picture as to what are main components of SharePoint. It would be useful, if they went through an exercise of installing SP on their box.
• Assuming you have SP available, .NET developers need to understand the relationship or core concepts between WebApplication/Site Collection/Site. This is similar to class having different scopes.
• The developers also need to understand at a high level what is Central Administration and what you can do with it.
• The developers need to create their 1st Web Application, Site Collection and Site. In addition, look at the file server as to what happens when a WebApplication is created. This is similar to what you do when you create a ASP.NET web. Explore the IIS Server to see the files that are added when you create a new web application.
• The developers need to understand that SP is nothing but a massive ASP.NET application and some of the principles they have learnt over the years as part of ASP.NET development can easily be reapplied in SP. Some of the concepts are caching, web configuration, session, query string parameters, relationship with IIS, HttpHandlers and HttpModules, postback events and so on.
Part 2:
• Assuming SP Site is available, the developers need to explore a site via browser and see what all components are available. You have to explain to developers and let them play with the different components of the Site.
• You should explore at creating different types of sites using the templates available, lists, content types, and columns and so on.
• Teach the developer to be aware of factors that help in deciding how many site collection you need for your given environment/solution. A good overview of what is within a site collection will be helpful.
• Next on the list is to expose the developer to SharePoint Designer. Let the developers try things in SP Designer and then view them in browser. I would also suggest that you spend some time with them in explaining what are bad things can (not) be done with SP Designer and how you can control it. This could be a good time to explain to them different security groups available (Farm Admin/Site Collection…)
• Once a developer has been familiarized with SharePoint Designer and accessing the site via browser and Central Admin, it may be a good idea to expose him to Power Shell. This should be a brief introduction to PowerShell as this is something that developers don’t necessary have to do as part of their daily job.
• Now expose the developer to the capabilities of InfoPath form. Give them an overview of what InfoPath forms can do and not do and where it is useful to use them as compare to not using them.
• This may be a good time for you to explain the developers about Site and Site Collection Features.
Part 3:
Assumption: At this point of time, the developer should have knowledge of the Site, Site Collection and Web, Central Administration, SP Designer, and Power Shell.
• Educate the .NET developer with what is in the SP Object model especially from Site Collection and below.
• Educate the developer on creating a basic Web Part and how it is deployed in the local environment. At this point it would be useful if you can explain the developer the differences between Farm Solution/Sandbox Solution and Visual Web Part and WebPart. During this process, explore the Visual Studio project and show the developer as to what is a Feature/Package.
• You could extend what was covered in the previous point to give them a better understanding of Feature and different scopes. This could take some time for the developer to understand, but this is critical.
• You should know expose the developer to 14 Hive in relationship to what was deployed above and some other things about 14Hive.
• Teach the developer to access a list programmatically and to do all the CRUD operations (LINQ/CAML) as well as events that are available.
• Teach the developer to create workflows in SP using a combination of SP Designer/VS and browser. You could give developer information about 3rd party products like K2 and Nintex that they can explore or read white papers in their spare time. During this step, you can tell the developers about Content Types as they would have picked some concepts in earlier part, but it may be useful.
• Teach the developer about the master page and application page as to how similar they are to ASP.NET master pages. The same theory holds true for page layouts/CSS etc. It may be useful to educate the developer on delegate controls as that is quite handy. You should also spend some time in explaining between different kind of pages that are available within SP and when is a particular page used.
• This is the natural extension of the last point where educate the developers on concepts like Ghosting/UnGhosting and Customization of Page.
• Teach the developers about Site provisioning, events associated with them and site templates.
• Teach the developer about BCS. BCS is further divided among the types of solutions where it no code or with code. No code is further divided among doing pure OOTB or some customization. The amount of time you want to spend on this topic would be directly proportional where you want to place this developer after they have completed the training.
Part 4:
At this point of time, your developer should be able to create basic Web parts that can access data from the Lists and then deploy it to their local environments comfortably. In this section of training, you have to just help the developer know about basic Software development process involved with SP. The .NET developer already knows how to do these things in non SP world, but they would not have an idea as to how to do things in SP.
• Teach them about checking in and checking out code from repository.
• Teach them about building packages and then deploying it via PowerShell.
• Teach them about what constitutes code as compare to content.
• Provide them with an overview of how SP development is done with teams and how the code is promoted all the way to Production.
• Teach them how to create their local environments.
• Teach developers about value of error handling that needs to be built in their code and some of the other developer items such as developer dashboard/ULS logging. This may be a good time to show them how you can control what events get logged in to SP via Central Administration.
• It may be useful to at least show the developer about SP jobs and you can create your own jobs.
Part 5:
At this point of time, your developer should be able to comfortably create a professional solution and then pass the package to administrator to be deployed in the next environment. Some of the other concepts that you can cover depending upon factors like time etc.
• MetaData and Taxonomy
• Web Analytics
• Content Organizer, Document Sets
• Client Object Model
• REST API
• Search – This is a very large topic, but you can give an overview of what is available within SP. Show the developer as to what can easily be accomplished without writing code. If required, you can also give overview of the object model that is associated with the Search for doing custom development.
• Excel/Access/Visio Service – Similar to search you can give an overview or if required go into the object model if there is any custom coding is required.
• Records Management.

Part 6: [Advanced]
• Security Model of assigning permissions via code.
• Claims Based Authentication
• Ribbon Customization
• Writing your own Custom Service.

As you see from the above program, the list of things that you need to teach in order to transform a .NET developer into a SP developer. If you have any questions or would like some more information please reach out to me via my LinkedIn account link.

Monday, August 15, 2011

SharePoint Search using Scope

In SP, you can easily slice and dice your content to search a specific document library or list. Last week, I posted an article that can be used when you want to search a given list on specific columns that are not exposed directly by METADATA.

In my experience, the below article would cover several business needs. These needs are specific to the clients I have worked with on Search. One of the needs is that we have so much of simillar data that when we search we get too much of results and not directly from the library that we are interested to get the data from. The other need is I need to get a list of all documents that have been modified/created/ by a user/date in this document library. You could have used a view here, but then that is specific and the user has to be educated. This cannot be dynamic.

Today, I am going to be documenting an Out of the BOX Scope feature that can be used perform a search specific to library/List/Sub Site. A user with site collection admin perms, can go to Site Settings->Search Scopes and then add a new Scope. Once you add a new item, then you can define the rules that are specific to the new Scope. After this, you have a choice of displaying this new Scope element in search box next on the top of the page and in the Basic Search Center's Advanced Search Page.

Assuming you have managed to get the above steps completed. Now, you need to go back to Central Admin- Services on Server-> Search-> Search and do a full crawl to have the new scope reflected in the Search Center. Once this has been completed, go back to Basic Search Center's Advanced Search Center page and you will be able use the new scope.
The same scope can also be developed using Visual Studio. This may be necessary when you have to repeat a process in multiple environments. In addition, some organizations don’t allow any direct updates so in that case you would need to write this scope via Feature and deploy it in your appropriate environment.
Next topic: Best Bets!

Friday, August 12, 2011

SharePoint Search on a Specific Document Library/List

How can you use OOTB search to perform search on a single specific list? When you perform a search, it will search those areas depending upon your content source, which is never specific to a single library containing documents. How can you perform a search where it only pulls the data from this given document library? You could use a common document property and then map it to perform your search. However, this is not a very consistent approach as some users may forget to do so. Therefore, it is better to use a column to create this feature. An alternative approach is to simply use scopes!

The key concept here is a metadata property that needs to be used. In this document, I will very briefly walk you through the process and show you how this can be extended to N number of document libraries. The same process can easily be applied to a list.

1: Create a document library for some finance group that you want to have a specific search upon. If that library exists, create a new column and call it MySearchColumn with a default value (Finance) and make sure the column is marked as not required field. Better, create a site column and then use it in this list. I will come back to why I suggested a site column.

2. Next, Go to the advanced setting of the Library and click on Manage content types. Once you do that, you will see the option to hidden the MySearchColumn from the form. This is a neat trick to hide the extra irrelevant column from the user and still maintain consistency. You could have let this column be there and the user could have asked you several questions. You could have educated the user on why you have this column in its place. You could have also written an event handler to ensure the value is consistent.
3. Now try adding a new document to the library and the MySearchColumn is not displayed on EditForm.aspx. Note, it will be visible from the “All Documents” view, but you can change this once you have completed the task.
4. Go to Central Administration -> Search Service Application->Search Administration and do a crawl. The reason you have to do this is so that the newly added column will be displayed in the MetaDataProperty.
5. Now create a new Meta Data Property by giving it a name “MyMetaDataProperty” that is mapped to ows_MySearchColumn. You should see this ows_MySearchColumn when you go to AddMapping. If you don’t see the column then there is a problem with your crawler or field name.
6. Next create a “Basic Search Template” that will be used to perform the search. When this is created a basic search page gets displayed. Click on the “Advanced Search”. On this page, edit the “advanced search webpart” to include this new property that you have created in Search Administration. When you click edit webpart, it displays you properties of the web part you can change. Click on properties section to open the box and then copy the XML into an XML editor where you need to add simillar following lines


Then, you need also include in the results section


7. Once this is completed, you should see 1 more managed property. Now, start a full crawl from
“Search Admin” and not an incremental crawl as the data from the new property will not show up.

8. Go to Advance search and choose the new property from the drop down below and choose equals “Finance” and perform you search. You should see results coming from that 1 single document library.

9. Similarly, if you have more document libraries you can reuse the same site column, but with a different value. The advantage of this approach is that you don’t have to set another meta data property and just put different value and you can now search exclusively in a different document library.









Wednesday, July 27, 2011

Power of Delegate Control- What/Why/How

I get a lot of questions from junior developer as to why use a delegate control and how do you implement a delegate control?

A delegate control is a control that will be rendered. The key thing here is that at the run time it finds all controls with the same id and then adds to tree the control with lowest seq number. The delegate control is mainly added to Master Page that is tied to your site. If you view the Master Page's code you will find several delegate controls as those are added by SP.

Why use a delegate control?
You will choose to use a delegate control if you want to add some code that is rendered on every single page in your site. The alternative way is you would add a user control containing your code to every single page on your site. If you create new page, then you have to remember to add this user control. This is not the best approach and for this reason you create a delegate control and add it to Master Page and then it is rendered on every page that uses this MasterPage. You can have more than 1 delegate control of the same ID, but the delegate control with the lowest seq will get added to the tree to render.

How do you create a delegate control?
There are 2 things involved in a delegate control.
- Master Page
- User Control created using Visual Studio.

Steps required to create DC
1. Create a new Empty SharePoint 2010 Project.
2. Map it to ControlTemplate Folder.
3. Right Click on ControlTemplate Folder and add a User Control.
4. Add your code in the User Control.
5. Right click on the project and add a module. This will create Elements.XML file
6. In the elements.xml add this code:





7. Delete the feature that got created and then add a new feature with a more meaningful name with information.
8. Open your MasterPage that is beeing used by your Site and add code like this

at top around the GlobalNavigation control.
9. Deploy your code and test it.

Where / How to store email address in SharePoint 2010 when using Claims

When you are using Claims based authentication method, the user is never added SharePoint SiteCollection unless the user has logged to the site for the 1st time. However, when a user logs into the site for the first time, its identifier is only stored in a UserList List.

If you have a need to send emails to user as per of workflow or alert or anything, you need to find a place to store them. You could easily use the UserList to store this information. As a user is entering your site, you could write code to query the claims to extract email address the user primarily has and then extract that value and store it to the User List.

The location of this list http://myserver/_catalogs/user/Simple.aspx

Specail Consideration with this list:
- User List is very notorious as to when it updates the data.
- Initially when you create a new Site Collection, this list shows less than 15 columns and then a timer job runs and it adds around 40 more columns to the list.
- This list can only be seen by Site Collection Admin and above.
- In order to update to this list, you should ue run with elevated privs.

I will post some sample code soon.

Monday, July 25, 2011

Auto Increment Columns in SharePoint 2010/MOSS

As more and more applications are using SharePoint to store data and they want it to work simillar to SQL. How do you create auto increment columns?

The process is pretty cool. It would require sing SPD workflow.

Here are the steps:
-Add another column to list (Note: You cannot use ID as that is the internal column)
-List Settings->Advanced Settings->Manage Content.
-From List Settings page, click Item Content Type, and then click new column name.
-Next, choose the option to hide the column in the form.
-Goto SPD and create a workflow with "Update Item" in the list action and then set the new column to a value with current item:ID .
-Check for errors->Publish - >Save
-Finally, don't forgot to check the workflow to be staretd automatically as this is not the default.

Demystify Title Column in SharePoint 2010 List/MOSS

When you create a new SP List, you see a default Title column. If you try to delete this column, you don't see the option to delete when you goto List Settings->Columns. Have you wondered why you cannot delete this column?

The answer is because when you create a custom list, it is created with "Item" content type. This "Item" content type has 1 field and it is required field.

How do you delete the Title column?

Goto List Settings->Advanced Setting -> Choose Manage Content Types.

Then, from List Settings-> Click Item Content Type and there you will get the optional to make changes to Title column!

Monday, July 18, 2011

Different Kinds of Pages in SharePoint 2010

Did you know there are 3 kinds of pages in SharePoint 2010

- WikiPages -> A new kind of page available in SharePoint 2010. Used primarily like a free for all wiki page for adding Tables etc. This may contain WebParts

- WebPart Pages -> Existed in SP2007 and SP2010 -> A more structured page with layouts/zones/webparts etc.

- Publishing Pages ->Specifically for publishing

In addition, there are Application pages that are physically stored on the server.

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, July 13, 2011

Troubleshooting: The user does not exist error or is not unique

Today I was rebuilding my VM as a result of some issue with the old VM. An authenticated claims user when added to a SPGroup threw the following error:

The user does not exist or is not unique.0x81020054"} System.Exception {System.Runtime.InteropServices.COMException}

I banged my head for some time before found out the problem was in the setup of WebApp. In my case, the WebApp had 2 STS Providers so it was pointing to the wrong STS Provider, which was causing the user to be not added to the group. However, the user was an authenticated user who could be directly assigned access to a resource, but not added to the group. The user was added and viewable from this URL-> http://YOURSERVER/_catalogs/users/simple.aspx.

The above solution is only applicable if you are using Claims Based Authentication.

SharePoint 2010 Administration Toolkit - Really cool

This is a great tool kit especially for administrators... Love the reports that are generated..This not only gives the reports, but also includes the following:

•Security Configuration Wizard (SCW) manifests
•Load Testing Toolkit (LTK)
•User Profile Replication Service
•Content Management Interoperability Services (CMIS)

Here is the link to install the kit

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.

How to create a Digicert.cer

Instructions
1. Open the YOUR.cer certificate.


2. Click on the Certification Path tab and highlight DigiCert. Click on View Certificate.

3. In the Details tab, click on Copy to File.


4. The Certificate Export Wizard appears. Click Next.


5. Select the default ‘DER encoded binary X.509 (.CER)’ option. Click Next.


6. Specify a file name and a location to export the certificate to. Click Next.


7. Click Finish to complete the Export Wizard. The digicert.cer certificate is created in the specified directory.

8. Run the following commands using SharePoint 2010 Management Shell to add the trusted root authority.
$root = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("c:\temp\digicert.cer")
New-SPTrustedRootAuthority -Name "YOUR Token Signing Root Authority" -Certificate $root

ADDING A TRUSTED ROOT AUTHORITY

The following command creates a new trusted root authority .

$root = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("c:\temp\YOUR.cer")
New-SPTrustedRootAuthority -Name "Token Signing Root Authority" -Certificate $root

If you receive an error that states that ‘The root of the certificate chain is not a trusted root authority’, like in the image...then you will need to get the root of the certificate and add it to SharePoint’s list of trusted root certificates

How to check which users have logged in SharePoint?

If you need to ever find out, which authenticated users have logged into your site, you need to visit this page. You have to be the Site Collection admin to see this list.

http://SERVER/_catalogs/users/simple.aspx

This will provide you the information about the user when was the 1st time the user ever logged into the site. This list is a hidden list. This list by default has 33 columns describing the user and the extended version of this list has 64 columns.

If you ever have a need to check when a user has logged in last time, you could simply add a small web part to the home page of your site. The main function of the web part is to update the list. When you update a row of data, it automatically puts the time stamp of the last modified date.

Here is some sample code:

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.Update();
}
}
}
catch (Exception e1)
{
Your Error Handling
}
});

Tuesday, June 14, 2011

Application Pages

Application Page rendering?

- Open VS 2010 and a feature project.
- Add an Application page. (VS will create layouts/project name (folder)/Name of the application page.
- Now deploy the feature.

Note: You can verify that the application page has been deployed by going to 14 Hive/Templates/Layouts/Project Name folder.

You can access the application page from this URL http://SERVER/_Layouts/Project/Application Page.aspx

However, if you access this page relative to a document library/list (Example: http://SERVER/DocumentLibrary/_Layouts/Project/Application Page.aspx, it does not give you 404, but gives you Rendering error!!!

Monday, June 13, 2011

How to prevent users from renaming folders?

Scenario: Need to prevent users from modifying the folder name in a document library
Solution: You need to add an item updating event to the library.

Here is some sample code:

try
{

if (properties.ListTitle == "YOUR LIBR")
{
//Only perform this check if the user is not a site collection admin.
if (!properties.Web.CurrentUser.IsSiteAdmin)
{
if (properties.ListItem.FileSystemObjectType == SPFileSystemObjectType.Folder)
{
properties.Cancel = true;
properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl;
properties.RedirectUrl = properties.WebUrl.ToString() + "/_Layouts/...../ErrorPage.aspx?errormessage=" + "Cannot rename the folder";
}
}
}

}
catch (Exception e1)
{
properties.Cancel = true;
properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl;
properties.RedirectUrl = properties.WebUrl.ToString() + "/_Layouts/..../ErrorPage.aspx?errormessage=" + e1.Message;
}
finally
{
if (!properties.Cancel)
{
base.ItemUpdating(properties);
}
}

}

A few notes:
- If you don't specify the redirect URL, SP will show a nasty dialog box like ASP.NET crashed or something with your message.This may not be liked by the business.

- You should always check for the type of object you want to prevent from getting updated.

- If there is a typo or you missed "/" in your RedirectURL, SP will display the nasty box and ignore going to ur Application page.

Thursday, June 2, 2011

List item limit 5000 details

I don't like the way Sharepoint has implemented the logic for 5k item. Consider a scenario where there are 7k items in the list in form of documents and folders. A non admin user clicks the list, Sharepoint at that time goes to SQL and fetches 1st 5k rows of data. In the UI you will by default see 30 items per page due to pagination. The user starts going next next and when it reaches 5k limit, it does not complain ithe browser keeps spinning!!!

I don't understand why it does not tell the user the reason it cannot process. More important, I don't like fact that since it is paginating why it needs to pull all 5k first time the user accesses the list.

Search not working

Followed all the instructions to enable search including, but not limited to following

- created a content source
- ensured the account used for crawling had access
- verified no cert warnings

Checked crawl logs. Everything looked clean but still when searched nothing returned

The problem alternate access mapping & reverse proxy!!!

Core.js blocked

Have you ever seen that core.js getting blocked ? Recently in my project we noticed that users were not able to see the drop down menu on any list items when they were accessing it from outside the network. Some of the functions of ribbon were also getting disabled. The problem was due to reverse proxy setup that was causing this error. Once we fixed the proxy issue it started working fine.

Friday, May 27, 2011

70-668

Studying for the 70-668 exam. This exam looks pretty cool. I started working on MeasureUp's test for this exam and I was scoring in 90% at my first attempts. I don't know if the questions are easy or I have learnt a lot while going through other 3 SharePoint 2010 certification exams. I guess time will tell....

Power Shell to get Content Database Size

Get-SPDatabase | Sort-Object disksizerequired -desc | Format-Table Name, @{Label ="Size(MB)"; Expression = {$_.disksizerequired/1024/1024}}

Thursday, May 26, 2011

How to create host-named site Collection

Ref: Msdn

I just had to put this up here as I was asked this in one of my interview questions a while back. Pretty cool stuff.

Create a host-named site collection
You must use Windows PowerShell to create a host-named site collection. You cannot use the SharePoint Server 2010 Central Administration Web application to create a host-named site collection, but you can use Central Administration to manage the site collection after you have created it.

You can create a host-named site collection by using the Windows PowerShell New-SPSite cmdlet with the -HostHeaderWebApplication parameter, as shown in the following example:

1.To create a host-named site collection using Windows PowerShell, verify that you meet the following minimum requirements: See Add-SPShellAdmin.


2.On the Start menu, click All Programs.


3.Click Microsoft SharePoint 2010 Products.


4.Click SharePoint 2010 Management Shell.


5.From the Windows PowerShell command prompt (that is, PS C:\>), type the following:


CopyNew-SPSite http://host.header.site.url -OwnerAlias DOMAIN\username -
HostHeaderWebApplication http://servername
This creates a host-named site collection with the URL http://host.header.site.url in the SharePoint Server 2010 Web application with the URL http://servername.

Programmatically create a host-named site collection
In addition to using the Windows PowerShell to create host-named sites, you can use the SharePoint Server 2010 object model. The following code sample creates the host-named site collection with the URL http://host.header.site.url in the SharePoint Server 2010 Web application with the URL http://servername:

CopySPWebApplication webApp = SPWebApplication.Lookup(new
Uri("http://www.contoso.com"));
SPSiteCollection sites = webApp.Sites;
SPSite Site = null;
Site = sites.Add("http://hoster.contoso.com", "Site_Title",
"Site_Description", 1033, "STS#0", "contoso\owner",
"Owner_Display_Name", "Owner_Email", "contoso\secondaryowner,
"Secondary_Owner_Display_Name", "Secondary_Owner_Email", true);
SharePoint Server 2010 ships with a set of Web services for various user and administrative tasks. One of these administrative tasks is creating a new site collection. The CreateSite Web service method does not support the creation of host-named site collections. A workaround for this issue is to write a Web service that wraps the API sample code.

Tuesday, May 17, 2011

PRO: 70-576 SharePoint 2010

This afternoon, I went ahead and took this certification exam offered by Microsoft. I was pleased that this exam had a couple of question on Claims and on Windows Authentication method. I think there were 10% question on security i.e. 5/50.

The questions on claims were straight forward.

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.

Tip: Creating WebApplications using Classic/Claims Mode

When you are creating a web application to use claims based authentication, ensure that the web application uses Claims based authentication. It is not possible to create a web application using classic mode and then extending it to use claims authentication mode.

Tip: Webapplication set up for Claims Based Authentication

It is better to set up a default WebApplication that connects to your AD and then extend the Web Application for Claims based authentication. One of the key advantages of this is that what if your Secured Token Services breaks down due to any reason and your manager needs some documents ASAP. A site collection admin can go into SharePoint site using their AD credentials to get you appropriate documents.

Therefore, you should have 1 Web Application and 1 extension.

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.