Querying Sub Folders with SPQuery Objects

March 19th, 2009 by kurtlubakla
With SPQuery class, we can search lists just like views.
 
Thik of a document library with lots of documents and sub folders. To get the filtered list of items in this document library, your code will be similar to the one below:
 

SPQuery

pagesQuery = new SPQuery();

pagesQuery.Query =

"<Where><Eq><FieldRef Name="FileID" /><Value Type="Text">" + FileID + "</Value></Eq></Where>";

 

pageUrl = currentWeb.Lists[pagesList].GetItems(pagesQuery)[0][pagesFileRefFieldName].ToString();

 

If you run this code, you'll see that the results of this query will only be from the root folder of the document library. If you want the result set to be from all items in the document library regardless of the folder the item in, you have to add this line of code for the SPQuery object below before executing the query:

pagesQuery.ViewAttributes =

"Scope="Recursive"";

If you get This item cannot be deleted because it is still referenced by other pages error while deleting a master page

March 19th, 2009 by kurtlubakla

Let's say you created a master page and put it to the Master Pages and Page Layouts Gallery. After a while, you wanted to delete the master page but you got the "This item cannot be deleted because it is still referenced by other pages". error. Do not be frightened. This is a bug and there is no solution for this situation. Microsoft offers a workaround for this situation which you can find at this link: http://support.microsoft.com/kb/926812

You do not have the rights to perform this operation Error on Single Sign On Configuration

March 19th, 2009 by kurtlubakla
Configuring single sign-on on MOSS 2007 can be a problem sometimes. Even you log in with an administrator account, when you want to create the SSO database at the "Manage Server Settings" page at "Manage settings for single sign-on" link, you can get a "You do not have the rights to perform this operation" error.
 
The solution to this problem is to give the same service account of SSO service as the SSO Administrator Account at the "Manage Server Settings" page, but if you do so, you have to log in to the Central Administration site with the SSO service account to configure SSO :( Sorry :(

Block File Types And "Unknown Error" Exception

March 19th, 2009 by kurtlubakla

If you just installed SharePoint and clicked the "Blocked File Types" link at the Central Administration site, you get the "Unknown Error" exception Why? Because, this is a bug :P If you haven't created any web application yet and opened "/_admin/BlockedFiledType.aspx" URL, the page can not populate the web application list menu on the right top and you get the "Unknown Error" exception :p Just go and create at least one web application, and that's it; the problem is solved :P

"The required Windows Rights Management client is present but the server refused access" Error

March 19th, 2009 by kurtlubakla

I installed the Active Directory Right Management Services role on Windows Server 2008 to test the IRM integration of MOSS 2007. When I clicked the "Information Rights Management" link on Central Administration site on MOSS 2007 and select "Use the default RMS server specified in Active Directory" option, I got the "The required Windows Rights Management client is present but the server refused access. IRM will not work until the server grants permission." exception. This error occurs because of the lack of NTFS permissions on related RMS web service. To overcome this issue, go to the "C:inetpubwwwroot\_wmcscertification" folder and assing read permissions to default content access account of MOSS 2007 installation on ServerCertificate.asmx file.

"Failure trying to synch web application" Error in WSS 3.0

March 19th, 2009 by kurtlubakla

My portal was working perfectly but SharePoint was consistantly logging the error below to the error log:

Failure trying to synch web application …, ContentDB … Exception message was A duplicate site ID … (http://…) was found. This might be caused by restoring a content database from one server farm into a different server farm without first removing the original database and then running stsadm -o preparetomove. If this is the cause, the stsadm -o preparetomove command can be used with the -OldContentDB command line option to resolve this issue.

This is logged when you detach and reattach a content database on SQL Server, or when you create a new web application with an existing content database. To solve this issue you can use the stsadm command below:

stsadm -o sync -deleteolddatabases

"The given key was not present in the dictionary" while backing up a web application

March 19th, 2009 by kurtlubakla

I created a web application. Then I extended the web application with a new host header url and deleted the first web application. Then, I wanted to backup the web application, but I got a "sharepoint KeyNotFoundException" exception while backing up. The description of the exception was "The given key was not present in the dictionary". To overcome this issue, I deleted the existing web application without deleting the content database, and I created a new web application using the existing content database. The problem was solved :P

Changing the alert e-mail delivery period on WSS 3.0

March 19th, 2009 by kurtlubakla

Since the alert e-mail sending architecture works with a the timer job that sends the alert e-mails every 5 minutes, the alert e-mails are not sent instantly. To change execution period of alert e-mail sending timer job, you can use stsadm.exe with command line parameters as below:

 stsadm -o setproperty -propertyname "job-immediate-alerts" -url http://yourmosssite -propertyvalue "every 1 minutes between 0 and 59"

 

Changing the delayed workflow activity control period in WSS 3.0

March 19th, 2009 by kurtlubakla

Let's say you have a "wait for 2 minutes and e-mail something" activity in your workflow in WSS 3.0. Since WSS 3.0 checks for delayed, paused workflow activities every 5 minutes, the workflow does not send the e-mail 2 mintues after the activity starts. So, if your requirement does not meet with this situation, you can configure WSS 3.0 to check the situation of the delayed workflow activities, let'ssay every minute. To do this, youc an use stsadm.exe with the following command line options: 

stsadm -o setproperty -propertyname "job-workflow" -propertyvalue "every 1 minutes between 0 and 59" -url http://localhost

File Stream data type in SQL Server 2008 and SharePoint

February 12th, 2008 by kurtlubakla

As we all know, SQL Server 2008 ships with many new features. One of these features is the File Stream data type.

Because of performance consideration, developers do not want to store files on SQL Server databases. File Stream data type stores the file on a physical folder instead of the database file itself, but we can "insert" or "select" the file just like it was stored on SQL Server database. 

SharePoint's document management module stores the uploaded files on SQL Server. This new data type will improve the performance of SharePoint. Unfortunately, usage of File Stream data type of SQL Server 2008 in SharePoint technologies will be avaliable with the new version of SharePoint. None of the service packs nor the hot fixes will change the way documents are stored on SQL Server 2008. Sorry Sad