Thursday, 3 May 2012

SharePoint 2007: How to execute immediatly a custom Timer Job?

One of the most frustrating things in Sharepoint for developers or even administrators, is implementing a new change and then have to wait for the next time in the schedule for the Timer Job to run.

For those who stumble upon this typical MOSS 2007 problem, and wish a particular timer job to execute immediatly:  I created a script that helps me out with it.
Arguments: URL TimerJobname(internal name not the name you see in the CA) ContentDBGuid

Source code:
Program.cs.txt (1.15 KB)

Enjoy!

SharePoint 2007: Property Import Mapping: AD properties cannot be mapped anymore

Once faced with this issue took me quite a while to figure it out. My customer had a recent AD serve rmigration to Windows 2008. Import users was working fine, but when a new property was requested to be mapped, it wa snot available anymore. See image bellow:

Note: The selection of directory service properties may be disabled if the shared service provider is in an untrusted domain or if profile import is not configured.
Note: The selection of directory service properties is disabled because the portal is in an untrusted domain or no irectory service import is configured yet.
Security Note: If you are using a high privilege account to import, you will be able to read and import directory

How was this solved?
1. Going to Shared Services >> User Profiles and Properties >. Configure profile import
2. Click on the link View import Connections
3. Edit the Import Connection
4. Specifiy a domain controller, picked a random controller,
5. Going back to the edit connection and press Auto Discover domain controller.
          
6. problem fixed.... totally random... totally worked!

Enjoy!

SharePoint 2007: Datasheet view not working 0x80070057

I've only found this problem in SharePoint 2010. When creating site columns through a feature, the site column type User can generate Datasheet view errors later on, if you forget to add the property Type="User" in the field description:

<Field ID="{cfede2eb-9f3b-4a6b-8bce-9880d2ea34fc}" SourceID="http://schemas.microsoft.com/sharepoint/v3" Name="FieldUserName" StaticName="FieldUserName" DisplayName="FieldUserName" Group="Field group" BaseType="Text" />

You should have done it like this:

<Field ID="{cfede2eb-9f3b-4a6b-8bce-9880d2ea34fc}" SourceID="http://schemas.microsoft.com/sharepoint/v3" Name="FieldUserName" StaticName="FieldUserName" DisplayName="FieldUserName" Group="Field group" BaseType="Text" Type="User" />

But now that you have deployed it live, the best way so data is not lost, is to correct this programmatically with a script:

static void Main(string[] args) {
string url = args[0];
SPSite site = new SPSite(url);

SPWeb web = site.OpenWeb();

List<SPField> fieldsList = new List<SPField>();

fieldsList.Add( web.Fields[new Guid("{cfede2eb-9f3b-4a6b-8bce-9880d2ea34fc}")] );

//you can add other User type fields where you have forgotten it. 

foreach (SPField field in fieldsList) {

Console.Out.WriteLine("Initial value: " + field.SchemaXml);

if (!field.SchemaXml.Contains("List="))

{

field.SchemaXml = field.SchemaXml.Replace("<Field", "<Field List=\"UserInfo\" ");

field.PushChangesToLists = true;

field.Update();

}
}


Good luck!

SharePoint 2007: Add Metadata to a folder

If you wish to add metadata to a Document library folder it is posible. Just follow through this nice step by step article: http://sharepoint-guru.blogspot.com/2007/06/adding-metadata-to-folder.html

SharePoint 2007: Code blocks are not allowed in this file

After editing a masterpage, or page layout you get the following error:

"An error occurred during the processing of /_catalogs/masterpage/masterpagename.master. Code blocks are not allowed in this file. "




Solution:


1. open the web.config add the following code in <sharepoint> <safemode..>:

<SharePoint>
<SafeMode MaxControls="200" CallStack="false" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="false">
<PageParserPaths>
<PageParserPath VirtualPath="/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />
</PageParserPaths>
</SafeMode>

....

2. Add the following safecontrol:

<SafeControl Src="~/_catalogs/masterpage/*" IncludeSubFolders="True" Safe="True" AllowRemoteDesigner="True" />


Good luck! :)

SharePoint 2007: Change the port for the Central Administration

This is piece of cake! Just apply the following command:

Stsadm –o setadminport –port 99999

This command will change SharePoint Central Administration v3 to run on port 9999. No need for IISRESET or reboot. Enjoy!

SharePoint 2007: The user doe snot exist or is not unique

When adding a user to a group, if it happens to get the error "The User does not exist or is not unique", can happen due to many reasons and usually after migrating a Portal. But if consistently happens to many different users. Try this!



1. check the following property:

stsadm -o getsiteuseraccountdirectorypath -url http://www.moss.com

2. if it returns something like:

<SiteUserAccountDirectoryPath>ou=team,ou=department,ou=company,

DC=domain,DC=com</SiteUserAccountDirectoryPath>

3. Try applying:

stsadm -o setsiteuseraccountdirectorypath -url http://www.site.com -path ""

Operation completed successfully.



This worked for me! Good luck!



reference: http://www.msexperts.org/blogs/mark/archive/2009/10/28/the-user-does-not-exist-or-is-not-unique.aspx