Tuesday, March 10, 2009

How to create custom 404 error pages for MOSS applications?


Based on my scenario. I had couple different applications and I was needed to specify different custom 404 error pages under each one. In order to implement it you need to follow steps below.

1. By default you can find error page under location below:

%systemdrive%\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\LangID - sps404.html

2. Make two copies of this page and paste under the same location.

3. I assumed that you have by this time two custom pages you. In IIS under each application create Virtual Directory. For example "Custom Errors" and paste your custom build error pages in each application.

4. Than go to step 2 and make changes in each page (copied from sps404.html)

Change the name of the page:

STSNavigate("/_layouts/spsredirect.aspx?oldUrl=" + requestedUrl);

To:

STSNavigate("/_layouts/NameofYourCustomErrorPage.aspx?oldUrl=" + requestedUrl);

Save it (Do the same for both pages)

5. Time to use CodePlex application (you can download SharePoint Manager 2007 here).

Run it. Select Application you need. In the properties window find the field - FileNotFoundPage and paste the name of error page (copied from sps404.html). Do that for both applications and save it. That's it - You all set.

_________________________________________________________________

Microsoft suggest follow steps below. You can find original article here.


How to point to a custom 404 error Web page in Windows SharePoint Services 3.0 or in Microsoft Office SharePoint Server 2007


To configure Windows SharePoint Services 3.0 or SharePoint Server 2007 to point to a custom 404 error Web page, follow these steps.

Note Because of a design limitation, the custom 404 error Web page does not work when you access invalid site collections.



  1. Log on to the computer that is running SharePoint Server 2007 by using an account that has administrative permissions.
  2. In Windows Explorer, locate the following folder:

    %systemdrive%\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\LangID

    Notes
    • In this path, %systemdrive% represents the actual drive name of the drive on which the operating system is installed.
    • In this path, LangID represents the actual language ID of the language that you use. For example, 1033 is the language ID for U.S. English.
  3. Create the custom HTML file. To do this, use the appropriate method.

    Microsoft Office SharePoint Server 2007


    loadTOCNode(3, 'moreinformation');
    1. On the computer that is running SharePoint Server 2007, copy the Sps404.html file to a temporary folder.
    2. Rename the Sps404.html file. For example, give the file the following name:

      Custom404.html

    3. Add the custom content to the Custom404.html file.
    4. Copy the Custom404.html file to the %systemdrive%\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\LangID folder.

    Windows SharePoint Services 3.0


    loadTOCNode(3, 'moreinformation');
    1. On the computer that is running Windows SharePoint Services 3.0, locate the existing Error.htm file in the following folder:

      %systemdrive%\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\LangID

      Notes
      • In this path, %systemdrive% represents the actual drive name of the drive on which the operating system is installed.
      • In this path, LangID represents the actual language ID of the language that you use. For example, 1033 is the language ID for U.S. English.


    2. Copy the Error.htm file to a temporary folder.
    3. Rename the Error.htm file. For example, give the file the following name:

      Custom404.htm

    4. Modify the Custom404.htm file as required.
    5. Copy the Custom404.htm file to the %systemdrive%\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\LangID folder.


  4. Create a custom console application by using Microsoft Visual Studio 2005 Professional Edition or Microsoft Visual Studio 2005 Standard Edition. Then, add the following code to the custom console application.

  5. // The following code assumes that a reference is made to Microsoft.SharePoint.



    Microsoft.SharePoint.Administration.SPWebApplication webapp =

    Microsoft.SharePoint.Administration.SPWebApplication.Lookup(new Uri("http://"));

    webapp.FileNotFoundPage = "";

    webapp.Update();




    Notes


    • In this code, <serverurl> represents the actual URL of the computer that is running SharePoint Server 2007.

    • In this code, <Custom404.htm> represents the actual name that you created for the custom HTML file.

    For more information about how to create a custom console application by using Visual Studio 2005, visit the following Microsoft Web site:

    http://msdn2.microsoft.com/en-us/library/ms438026.aspx (http://msdn2.microsoft.com/en-us/library/ms438026.aspx)

    Note By default in Windows SharePoint Services 3.0 and in SharePoint Server 2007, the FileNotFoundPage property is set to the "null" setting.


  6. Run the custom console application on the computer that is running SharePoint Server 2007.

Note By default in Windows Internet Explorer, the Show friendly HTTP error messages setting is turned on. In this case, the custom error page may not appear. For more information about this setting, click the following article number to view the article in the Microsoft

Monday, February 9, 2009

CabLib Compress ERROR: Could not flush cabinet: Could not create cabinet file Title is required

If you get this error during building WSP it is because your files have “read only" properties. Check Out files (in Visual Studio or another editor) or Right Click folder -> Properties and Uncheck "Read only".
Build WSP again.

Saturday, January 24, 2009

The search request was unable to connect to the Search Service.

In order to resolve this error "The search request was unable to connect to the Search Service.":
1. Go to the server:
Run > Type “Services.msc” - >
- Start a SharePoint search service;
- Start Indexing service;
- IISReset

Friday, January 23, 2009

Sharepoint Service Error: A deployment or retraction is already under way for the solution *.wsp

Sharepoint Service Error: A deployment or retraction is already under way for the solution *.wsp

To resolve this problem do the next steps:

Click "Start", click "Run" type cmd

The operation below shows you all runnig deploying process:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN>stsadm -o enumdeployments

Base on GUI of process you can cancel it. Use next operation for that:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN>stsadm -o canceldeployment -id "GUID job ID"

Tuesday, January 13, 2009

Security Classes

SPGroup
SPUser
SPRoleAssignment
SPRoleDefinition

Setting Unique Folder Permissions

SPPrincipal principal = userToAdd;
SPFolderCollection submissions = web.GetFolder("Submissions").SubFolders;
SPFolder newFolder = submissions.Add("testfolder");

SPListItem folderItem = newFolder.Item;
folderItem.BreakRoleInheritance(true);
folderItem.Update();
SPRoleAssignment folderRoleAssignment = new SPRoleAssignment(principal); SPRoleAssignmentCollection folderRoleAssignments = folderItem.RoleAssignments; SPRoleDefinitionBindingCollection folderRoleDefBindings = folderRoleAssignment.RoleDefinitionBindings;
folderRoleDefBindings.Add(roleDefinitions["Contribute"]);
folderRoleAssignments.Add(folderRoleAssignment);

Adding User to a SharePoint Group

web.AllowUnsafeUpdates = true;
SPGroup studentsGroup = web.Groups["Students"];
SPUser userToAdd = web.SiteUsers["pilothouse\\testgroup"];
studentsGroup.AddUser(userToAdd);
Response.Write("Added user successfully");

Role Assignments For the Site

SPRoleAssignmentCollection webRoleAssignments =
web.RoleAssignments;

Response.Write("All role assignments in this site: " + "
");

foreach (SPRoleAssignment webRoleAssignment in webRoleAssignments)
{
Response.Write(webRoleAssignment.Member.Name + " "
+ webRoleAssignment.RoleDefinitionBindings[0].Name + " "
+ webRoleAssignment.Parent.ToString() + "
");
}

Role Definitions

// Role definitions are represented as "Permissions Levels"
// in user interface

SPRoleDefinitionCollection roleDefinitions = web.RoleDefinitions;
Response.Write("All role definitions in this site: " + "
");
foreach (SPRoleDefinition roleDefinition in roleDefinitions)
{
Response.Write(roleDefinition.Name + "
");
}

SharePoint Group Users

// All users in "Students" SharePoint group
users = web.Groups["Students"].Users;

Response.Write("All users in \"Students\" SharePoint group: " + "
");
foreach (SPUser user in users)
{
Response.Write(user.Name + "
");
}

SharePoint Group Security Principals

// SharePoint Groups that are Security Principals on this website
SPGroupCollection groups = web.Groups;
Response.Write("All SharePoint groups in this site: "+"
");
foreach (SPGroup group in groups)
{
Response.Write(group.Name + "
");
}

// All SharePoint Groups in this site collection
groups = web.SiteGroups;
Response.Write("All SharePoint groups in this site collection: " + "
"); foreach (SPGroup group in groups)
{
Response.Write(group.Name + "
");
}

Domain User and Group Security Principals

// All domain users and groups
// that are Security Principals for the website
// This is the list you see in /_layouts/user.aspx

SPUserCollection users = web.Users;
Response.Write("All domain user principals in this site: " + "
"
);
foreach (SPUser user in users)
{
Response.Write(user.Name + "
"
);
}

// All domain users and groups within the site collection
users = web.SiteUsers;
Response.Write("All users in this site collection: " + "
"
);
foreach (SPUser user in users)
{
Response.Write(user.Name + "
"
);
}

Security Permission Inheritance

SPSite site = SPContext.Current.Site;
SPWeb web = SPContext.Current.Web;

// Test to see if the site has unique permissions
if (web.HasUniqueRoleAssignments)
{
Response.Write(web.Title + " does not inherit permissions
"
);
}
else
{
Response.Write(web.Title + " inherits permissions
"
);
}

Monday, January 12, 2009

Uncustomized and Customized Pages

Ghosted - Uncustomized
Unghosted - Customized

In WSS v3 pages exist in one of two states: customized or uncustomized. An uncustomized page is one that is listed in the site's contents database, but the actual source of the page (the file) resides on the file system, and the content database simply contains a link pointing to the file. A customized page is also listed in the content database, but the source of the page is also stored in the database. Future requests for that page (in the context of a specific site) will be served from the database, not from the file system.

Saturday, January 10, 2009

SharePoint Development using C#

Before you start developing you need a reference to "using Microsoft.SharePoint;" namespace.

Working with a list

Short description of some classes:

Site Organization Classes
SPContext -
SPWebCollection -
SPListCollection -
SPWeb - represents site;
SPSite - represents site collection;
SPList -


List Classes
SPField -
SPView -
SPListItem -



Getting the Current Website
SPWeb web = SPContext.Current.Web;

Site Collection Navigation

SPSite siteCollection = SPContext.Current.Site;
SPWeb rootWeb = siteCollection.RootWeb;
TreeNode rootNode = new TreeNode(rootWeb.Title);
treeSiteCollection.Nodes.Add(rootNode);
addSubWebsToTree(rootWeb, rootNode);

Create a list
SPWeb web = SPContext.Current.Web;
web.AllowUnsafeUpdates = true;

SPList list;
try
{
list = web.Lists["Student Assignments"];
}

catch(Exception ex)
{
System.Guid listID
= web.Lists.Add("Student Assignments", "", SPListTemplateType.Tasks);
list = web.Lists[listID];
}

Creating a column in a list
SPFieldCollection fields = list.Fields;
SPField gradeField;
if (fields.ContainsField("Grade"))
{
gradeField = fields["Grade"];
}
else
{
fields.Add("Grade", SPFieldType.Number, false);
}

Adding Field to default view of the list
SPView defaultView = list.DefaultView;
if (!defaultView.ViewFields.Exists("Grade"))
{
defaultView.ViewFields.Add("Grade");
defaultView.Update();
}

Creating a new list item
SPListItemCollection items = list.Items;
SPListItem newItem = items.Add();
newItem["Title"] = "Homework 1";
newItem["DueDate"] = System.DateTime.Now;
newItem["Grade"] = 5; newItem.Update();

Sunday, January 4, 2009

Single Sign On Administration

Single Sign On –allow users to authenticate once into SharePoint and then access other applications such as Siebel or SAP using mapped credentials from encrypted credentials database. Administrators and developers use supporting application interfaces to manage single sign on credentials

Application Definition – metadata (username, passwords, group) about an application that that will be accessible through single sign on.

Saturday, January 3, 2009

Solution Deployment

Solution is a cab file with a manifest file that contains:
  • Feature definitions 
  • Site Definitions 
  • Resources –Assemblies (DLLs) that implement related functionality 

Solution is very similar to a web part package in SharePoint 2003

The “Global” Template

SharePoint provisions “Global” template before any other template

The template includes:

– Base type list schema definitions
•Generic List
•Document Library
•Discussion Forum
•Issues List
•Survey List

- Gallery Lists
•Master Page Gallery
•Web Part Gallery – only at the root site
•List Template Gallery – only at the root site
•Site Template Gallery – only at the root site
•User Information List – only at the root site

- Features
•Content Types
•Site Columns (Fields)
•Mobile Redirect

Site Definitions in 2007: Folder Structure

Program files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\

•GLOBAL – contains “Global Template” site definition

•SiteTemplates
- STS
- default.aspx
- XML
- onet.xml – references features
- does not contain base types
- does not contain list templates
- MPS

•FEATURES – contains all SharePoint and custom features
- CustomList
- Navigation
- DocumentLibrary
– document library feature
- ListTemplates
- DocLib.xml
- DocLib
- Schema.xml – DOES NOT CONTAIN
- Upload.aspx
- No allitems.aspx or editform.aspx
 
Sell my car, Used car for sale, Free Automotive Classifieds