Showing posts with label stsadm. Show all posts
Showing posts with label stsadm. Show all posts

June 5, 2009

MOSS: Unable to import custom SPFields of type User

Problem:
Imagine the following scenario: You have created custom SPField for your Content Type. SPField is of type "User", i.e., a PeopleEditor field where you can select a one or several Active Directory users or groups.

In my case the SPField definition is something like this:

<Field ID="{UNIQUE_GUID}"
Name="ProjectOwner"
Group="MyGroup"
Type="User"
DisplayName="Project Owner"
SourceID="http://schemas.microsoft.com/sharepoint/v3/fields"
StaticName="ProjectOwner"
Required="FALSE">
</Field>

Then you do a STSADM EXPORT and IMPORT for the SPWeb using Content Type using this SPField.

STSADM EXPORT succeeds, but STSADM IMPORT throws error:

Progress: Importing ListItem /a/windows-hardening/Pages?id=1.
FatalError: Value cannot be null.
Parameter name: g
at System.Guid..ctor(String g)
at Microsoft.SharePoint.Deployment.ListItemSerializer.UpdateFieldData(SPListItem listItem, ImportObjectManager objectManager, Guid docId, String fieldName, String value, String value2, Guid gFieldId, Boolean& bCreated, Dictionary`2 brokenFields)
at Microsoft.SharePoint.Deployment.ListItemSerializer.UpdateFieldData(SPListItem listItem, Guid docId, Boolean& bCreated, SPContentTypeId contentTypeId, ImportObjectManager objectManager, Object data)
at Microsoft.SharePoint.Deployment.ListItemSerializer.SetObjectData(Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
at Microsoft.SharePoint.Deployment.XmlFormatter.ParseObject(Type objectType,Boolean isChildObject)
at Microsoft.SharePoint.Deployment.XmlFormatter.DeserializeObject(Type objectType, Boolean isChildObject, DeploymentObject envelope)
at Microsoft.SharePoint.Deployment.XmlFormatter.Deserialize(Stream serializationStream)
at Microsoft.SharePoint.Deployment.ObjectSerializer.Deserialize(Stream serializationStream)
at Microsoft.SharePoint.Deployment.ImportObjectManager.ProcessObject(XmlReader xmlReader)
at Microsoft.SharePoint.Deployment.SPImport.DeserializeObjects()
at Microsoft.SharePoint.Deployment.SPImport.Run()

Thoughts:
If you use -nofilecompression parameter when exporting and importing using STSADM, you can look at the exported Manifest.xml and see the difference between fields that have List="UserInfo" and the ones that don't.

OOB field PublishingContact value is exported like this:
<Field Name="PublishingContact" Value="2;UserInfo" FieldId="6677cf63-f416-4e1e-9e6e-f77f243ef4a6" />

while custom ProjectOwner field value without List="UserInfo" in its definition is exported like this:
<Field Name="ProjectOwner" Value="2;691e9a30-76c4-42b6-869f-294c2c68267d" FieldId="6677cf63-f416-4e1e-9e6e-f77f243ef4a6" />

You can see that the custom field contains the GUID of the list where the item is located in, while the OOB field contains clear reference to UserInfo list.

Solution:
First of all, remember to always include List="UserInfo" when defining SPFields of type "User", like this:

<Field ID="{UNIQUE_GUID}"
Name="ProjectOwner"
Group="MyGroup"
Type="User"
DisplayName="Project Owner"
SourceID="http://schemas.microsoft.com/sharepoint/v3/fields"
StaticName="ProjectOwner"
Required="FALSE"
List="UserInfo">

</Field>

If you realize this requirement too late, you can modify the exported Manifest.xml and replace the values of the fields affected from:

<Field Name="ProjectManager" Value="2;GUID_OF_PAGES_LIST" FieldId="6677cf63-f416-4e1e-9e6e-f77f243ef4a6" </>

to

<Field Name="ProjectManager" Value="2;UserInfo" FieldId="6677cf63-f416-4e1e-9e6e-f77f243ef4a6"</>

and import after that.

In addition you need to have custom application that enumerates all existing items and fix field definition on them using API.

January 7, 2008

MOSS: Backup and restore path-scoped and host-scoped site collections

Problem:
You cannot backup a host-based site collection and restore it as a path-based site collection. For example, you cannot backup site collection from http://service.company.com and restore it to http://anotherservice.company.com/sitecollection.. You could restore it without problems to http://anotherservice.company.com.

The backup and restore procedures will most probably succeed, but you will run into strange "File not found" errors when accessing some sites. Some sites work fine, but others give the error. When you run IISRESET sites that were working might start giving the error as the sites that were giving the error might start working.

Workaround:
According to MS Support, the site structure must be the same in source and destination environments. So, what it means, is that you cannot really use stsadm backup/restore for moving content between different environments if the structure of the web applications differ.

According to MS Support, the following steps should function as a basis for a workaround, although I haven't tried it. Basically what you do is that you alter the web application site collection structure in source environment before taking the backup. If you have tried this and it worked, please let me know.

Source environment:
Site collection 1: http://serviceA.companyA.com
Site collection 2: http://serviceB.companyA.com

Destination environment:
http://serviceA.companyB.com/serviceB
(where http://serviceA.companyB.com is site collection 1 an /serviceB is site collection 2)

So, the two site collections are backed up from source environment and combined under the same URL in destination environment so that source's site collection 2 is located under the site collection 1.

And finally, the steps for the workaround:
  1. In source environment, create another site collection underneath the Web application where your site collection 1 is located (http://serviceA.companyA.com/serviceB)
  2. In source environment, backup site collection 2
  3. In source environment, remove site collection 2, the web application it belonged to and associated Databases
  4. In source environment, restore the backup of the site collection 2 to the new site collection you created under site collection 1 (http://serviceA.companyA.com/serviceB) in step 1.
  5. Backup and restore to the destination environment.

Solution:
Unknown

June 14, 2007

MOSS: stsadm setproperty returns "Command line error"

Problem:
Trying to run commands such as:

stsadm -o setproperty -url http://url.to.site.com:80 -pn "peoplepicker-searchadforests" -pv "domain:my.domain.com"

return error message Command line error.

Solution:
Use stsadm.exe like this:

stsadm.exe -o setproperty -url http://url.to.site.com:80 -pn "peoplepicker-searchadforests" -pv "domain:my.domain.com"

Logical:
No, but not many things are in MOSS.