Archive for category Sharepoint

Sharepoint 2007: Trace Management Service unable to delete file ‘Filename’. Error 5

After moving your MOSS log files (etc. c-drive to d-drive) around, you are possible missing few folder permissions. Your MOSS log files are not deleted and are filled with the error in the title.

Add MODIFY rights to LOCAL SERVICE account in the new logs-folder and your error should be history.

WSPBuilder: How to enable custom workflows in existing project

 I had an old WSPBuilder project and I wanted to add workflow to it. The old project was created with WSPBuilder project template and with .Net Framework 2.0.

For people who are not interested in my strugle with this problem, skip these first 12 steps :)  For others, these are the steps I had to go through:

  1. I tried adding WSPBuilders Sequential Workflow Feature workflow directly to the project. It worked nicely.
    • After that I got three reference warnings (System.Workflow.Activities, .ComponentModel and .Runtime)
  2. I had to change target framework from 2.0 to 3.5. (Right click on project -> properties -> Target Framework). After that the references worked.
  3. I opened the workflow feature to designer mode and was greeted with these two nice messages
    • The service ‘System.Workflow.ComponentModel.Compiler.ITypeProvider’ must be installed for this operation to succeed. Ensure that this service is available.
    • The service ‘System.Workflow.ComponentModel.Design.IIdentifierCreationService’ must be installed for this operation to succeed. Ensure that this service is available.
  4. After some googling  Binging I found out that I needed to add more project type GUIDs to my *.csproj file.
    • Right click on project -> Unload project. Right click on project -> Edit *.csproj
    • Change the key <ProjectTypeGuids> to the following line
    • <ProjectTypeGuids>{F8810EC1-6754-47FC-A15F-DFABD2E3FA90};{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    • Right click on project -> Reload project
  5. Yeah, now I could edit the workflow in designer!
  6. I drag-and-dropped few tasks to the workflow, tried building it and it was good! I was already very excited to get this thing working.
  7. Deployed the solution to MOSS. Right click on project -> WSPBuilder -> Build WSP. Right click on project -> WSPBuilder -> Deploy.
  8. Added workflow to list and created new item. Nothing happened…
  9. Checked the workflow status and reviewed the logs to find these messages
    • From workflow status: Failed on start (retrying)
    • From MOSS logs: Engine RunWorkflow: System.Workflow.ComponentModel.Compiler.WorkflowValidationFailedException: The workflow failed validation
  10. After some more Binging found out that I also have to add some target-files (what every those are…)
    • Right click on project -> Unload project. Right click on project -> Edit *.csproj
    • Add the following new the key under the existing <Import Project=”$(MSBuildBinPath)\Microsoft.CSharp.targets” />
    • <Import Project=”$(MSBuildExtensionsPath)\Microsoft\Windows Workflow Foundation\v3.5\Workflow.Targets” />
    • Right click on project -> Reload project
  11. Build, deploy and have fun with your workflow!

And here is the same info in a nutshell:

  1. Change the projects target framework to 3.5
  2. Unload your project and modify your *.csproj file
  3. Change the project type GUIDs to this
    • ProjectTypeGuids>{F8810EC1-6754-47FC-A15F-DFABD2E3FA90};{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
  4. Add this line under the existing <Import Project=”$(MSBuildBinPath)\Microsoft.CSharp.targets” /> key
    • <Import Project=”$(MSBuildExtensionsPath)\Microsoft\Windows Workflow Foundation\v3.5\Workflow.Targets” />
  5. Reload project, build, deploy and enjoy!

An unhandled exception occurred in the user interface.Exception Information: OSearch (Administrator) & SPSearch (Administrator)

I got these errors when starting both Search Services from sharepoint central admin. The problem occurred because I just defined the username, not the computer name or domain name. The services started working after I entered username like domain\username.

Sharepoint Event ID 6102 – LoadBalancer.RegisterLauncher failed

I have this problem in my environment, but still haven’t quite figured it out. Event log shows error every 30-60 seconds and the error is like this:

Event Type: Error
Event Source: Office SharePoint Server
Event Category: Launcher Service
Event ID: 6102
Date: 8/10/2009
Time: 8:00:00 ÁM
User: N/A

Computer: server1

Description: LoadBalancer.RegisterLauncher failed: Unable to connect to the remote server

Here’s a list of different possible solutions to this problem:

  • Go to the Sharepoint Central Administration -> Operation -> Service Account. Change Load Balancer service account to “Network Service” or “Local Service”
  • Restart the Document Conversion Load Balancer service and Document Conversion Launcher service with services.msc (win+R -> services.msc)
  • Problems with SSP: add more permissions to the SSP user, create new SSP
  • Shutdown Document conversion launcher service and document conversion if you don’t need them
  • Add read/execute permissions for IIS_WPG group to the Inetpub-folder
  • Change IIS Application pool identity for sharepoint to “Local System”

Sharepoint: Increase maximum size of list templates

If you have ever needed to move/copy “large” document librarys, you’ll know the not so great default setting of template maximum size. By default template can only be 10 Mb, but there’s a way to make it accept more larger templates. Using STSADM you can set the maximum template size to anything you like. In this example it will be set to 500Mb (insert value in Kb).

STSADM –o setproperty –pn max-template-document-size –pv 512000

Programmatically browse and get permissions from sharepoint site

I was “ordered” to go through hundreds of pages and collect permissions from them to create document of current user permissions for auditing. I was too lazy for that and wrote this piece of code that prints the sites name, url and permissions to console and then continues to go through all the sites under the starting site. You can also save the output to a file when running the executable from command line with the pipe command “program.exe > output.txt”.

?View Code CSHARP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
 
class Program
{
static void Main(string[] args)
{
try
{
using (SPSite siteCollection = new SPSite("http://localhost"))
{
using (SPWeb root = siteCollection.OpenWeb("SiteA/"))
{
string indent = string.Empty;
Console.WriteLine(indent + "-----------------------");
Console.WriteLine(subsite.Title + "\t" + subsite.Url);
Console.WriteLine(indent + "-----------------------");
writePermissionsFromSite(root, 1);
WriteSubSites(root, 1);
}
}
}
catch (Exception ex)
{
Console.WriteLine("Exception: " + ex.StackTrace);
}
}
private static void WriteSubSites(SPWeb root, int depth)
{
string indent = string.Empty;
for (int i = 0; i &lt; depth; i++)
{
indent += "\t";
}
foreach (SPWeb subsite in root.Webs)
{
Console.WriteLine(indent + "-----------------------");
Console.WriteLine(indent + subsite.Title + "\t" + subsite.Url);
////Console.WriteLine(indent + subsite.Title);
Console.WriteLine(indent + "-----------------------");
writePermissionsFromSite(subsite, depth + 1);
if(subsite.Webs.Count &gt; 0)
{
WriteSubSites(subsite, depth + 1);
}
}
}
 
private static void writePermissionsFromSite(SPWeb subsite, int depth)
{
string indent = string.Empty;
for (int i = 0; i &lt; depth; i++)
{
indent += "\t";
}
 
if (subsite.Permissions.Inherited)
{
Console.WriteLine(indent + "P: inherited");
}
else
{
string roles = string.Empty;
 
foreach (SPRoleAssignment permission in subsite.RoleAssignments)
{
roles = string.Empty;
foreach (SPRoleDefinition role in permission.RoleDefinitionBindings)
{
 
roles += role.Name + "; ";
}
 
Console.WriteLine(indent + "P: " + permission.Member.Name + " - " + roles);
}
}
}
}

MOSS Access Denied troubleshooting

In case you or your users are experiencing random access denied messages when browsing sharepoint, read this great article written by Tyler Holmes

MOSS 2007, Windows 2008 and HOSTS-file

Sharepoint wants to save it’s address to the computers HOSTS-file (%systemroot%\system32\drivers\etc\HOSTS) and that’s a file that windows server 2008 by default does not even have and really does not want any users writing to it. Even if your user (running sharepoint as admin is not recommended) has admin rights, sharepoint is unable to write anything to the HOSTS-file. You need to take ownership of the folder etc and then add either the sharepoint farm admin or the WSS_ADMIN_WPG group.

Joseph Davis has written a step by step article about this here.

Sharepoint: Fixing Corrupted Web.config

After playing around with some sharepoint features that wrote their settings to web.config I was left with a problem. After uninstalling the settings were still in the web.config and I had to manually remove the lines. It didn’t take long for the settings to reappear to the web.config. After some googling I found interesting blog post about this exact problem.

Because of my history with basic ASP.NET pages I presumed that the web.config would be just a static XML-file on the harddrive but I couldn’t been more wrong. Sharepoint stores programmatically added (Read more from MSDN) web.config modifications in the SQL database (by default) called Sharepoint_config_[GUID]. Randomly (server reboot, feature install/uninstall, IISRESET…) sharepoint recreates the whole web.config. It keeps the lines that are added or not stored in the config-database, but every line that exists in the database will be overwritten.

You can check the stored web.config modifications from the SQL server with a query: 

SELECT Id, ClassId, ParentId, Name, Status, Version, Properties
FROM Objects
WHERE    (Name LIKE ‘%WebConfig%’)

The interesting part is the column named ‘Properties’, because it contains the actual web.config modifications. The string is in XML-format so you are better of to just copy-paste it to some program, that knows how to format XML-properly (ex. Visual Studio)

From the same blog where I found description of this problem I also found two different solutions:

  1. Old school way (harder)
    • Direct manipulation of the SQL data. You can read the instructions from here.
  2. New school way (Easier)
    • Install “Web.Config Modifications” add-on to the Central Administration and delete the data from there. I’ve used this few times now and it’s really easy!
    • Now there’s also updated version from Harmjan Greving. You can download it from here.

But always remember that Microsoft does NOT support directly altering the data from the SQL server so don’t forget to take backups before doing this!

Tags: , ,