Thursday, December 30, 2010

Configuring SSO (Single Sign On ) in Sharepoint 2007

There are seven main activities that we need to do:
1. Create the SSO service account -- This is the account that the service will run under.
2. Create the SSO groups -- These groups are used to control who has the ability to administer SSO (export the master key) and who has the ability to manage it (add/remove application definitions.)
3. Configure the SSO Service - Set SSO to start and get it to use the service account.
4. Configure SQL Server - Authorize the SSO service account to SQL server.
5. Manage SSO - Setup SSO in MOSS including the groups and the database.
6. Manage the encryption key -- Create the encryption key that will be used for protecting the username and password information on the system.
7. Manage settings for enterprise application definitions -- Define what initial applications SSO will be setup to manage passwords for.

Adding Validation to a Custom List Control in Sharepoint

Introduction
Recently, one of the requirements was to put validation to a custom List control such as Email field validation.
This validation can be achieved from inside the SharePoint designer.
Following is a step by step walkthrough to validate a list field.
Background
You should know how to create a sharepoint list and how to open the site in sharepoint designer.
1. Following is a list with Email fields. Let's say we have to validate so that only a valid email can be entered.
If not valid, then the Error Message appears next to the field:


2. Now open the site in the sharepoint designer and then expand the list and open the Newform.aspx of the list to be validated:



3. As you can see in the image above, the Newform.aspx of Validation list is being opened in the sharepoint designer.

4. Now right click on this Validation list Web part in sharepoint designer and choose Web Part properties:

5. The properties dialog box will open for the Validation list here. Choose Hidden under layout and say OK.
(This web part can be deleted as well, but due to some known problems because of deletion, it is best to hide this).

6. Now click exactly underneath the hidden list web part and go to Insert->Sharepoint Controls-> Custom List Form… and the Wizard will ask to choose a list or Document Library form based on existing list.
Choose your Validation list and select New item form under type of form to create option and hit Ok.

7. You will get the Validation list underneath the hidden list as shown as selected image below:


8. Now from here, we can customize all the controls based on requirement. As we are customizing the E-Mail field, right click on the email field box and choose Show common control tasks from the context menu:

9. This will give you Common Formfield tasks option as shown below next to the Email field. Here we can change the format of the data field selected (default is list form field). As we need Email field to be textbox where validation can be applied, Choose Textbox from Format as dropdown instead of list form field.

10. After the above step, list will look like this (custom formatted):

11. Now drop a RegularExpressionValidator control from the Validation option under ASP.NET controls from the toolbar as shown below:

12. Now specify the required properties (such as ControlToValidate, ErrorMessage, SetFocusOnError to true, Validate Expression) of the RegularExpressionValidator from the Tag Properties toolbar. For ControlToValidate, choose the ID of the Email field.
After selecting it and getting the ID from the Tag Properties toolbar as you do in Visual Studio, see below the set attributes in blue for the Email field:

13. Now, save the changes and go back to the list in Internet Explorer and try to type in an invalid email id and you will get the following:

Sharepoint 2007 : Item-level permissions





It interests me because it

* allows you to control ownership of the item
* is only available to Lists but not to Document Libraries
* doesn't use unique permissions but some other mechanism

One thing it mentions is that it only works for users without Manage Lists permission on the list. So even if I manage to unravel its' secrets it isn't a waterproof solution (compared to unique item permissions for example). Still, if SharePoint has the notion of ownership it is definitely worth a closer look ! Maybe there's an opportunity here ?

It definitely isn't security by obscurity; if I navigate directly to an item that's not mine I still can't access it.

Peeking under the hood reveals that this setting is stored in SPList.ReadSecurity and SPList.WriteSecurity. Those MSDN articles contain all the details so I'll try not to be repetitive

ReadSecurity

Possible values:

* 1 - All users have Read access to all items.
* 2 - Users have Read access only to items that they create.

WriteSecurity

Possible values:

* 1 — All users can modify all items.
* 2 — Users can modify only items that they create.
* 4 — Users cannot modify any list item.

What about Document Libraries ?

For a Document Library these properties always have a value of "1" meaning everyone has read and write access (provided their permission level is sufficient). Since there is no interface in the Library Settings they cannot be changed. However nothing is stopping me from writing a few lines of code to update the settings, is there ?

using (SPSite site = new SPSite("http://moss/demo1"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["Shared Documents"];
list.ReadSecurity = 2;
list.WriteSecurity = 2;
list.Update();
}
}

Guess what ? It worked fine in the standard SharePoint Views and queries but not for WebDAV (Explorer View, etc). Probably the reason they only use it on SharePoint Lists.

An opportunity ? Not really since it doesn't act as real security in all scenario's. At least my curiosity is satisfied.