Sharepoint notes, hints and fixes …

What I have learnt so far with Sharepoint.

1. Google is your friend.

2. Have your own dev vm so you can test and break things, snapshots are handy.

3. Logs logs logs. If there’s a problem, there’s a good chance it’s in the logs.

4. Keep a record of the useful commands you’ve used, and how you used them. There’s a good chance you’ll need them again 



Restoring a backup from a different SQL Server

FROM DISK = ‘\\.host\Shared Folders\SQL Backups\master_backup_200903310300.bak’ 


   FROM DISK = ‘\\.host\Shared Folders\SQL Backups\master_backup_200903310300.bak’
      MOVE ‘master’ TO ‘E:\master.mdf’ ,
      MOVE ‘mastlog’  TO ‘E:\master.ldf’, REPLACE


After a restore of some tables, database is out of sync:

Run this command:

disconnected from farm, reconnected to farm
stsadm -o sync -deleteolddatabases 5 – if no portal sites

List users in AD before they’re in Sharepoint

On Error Resume Next


Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

objCommand.CommandText = _
    "SELECT Name, userPrincipalName, sAMAccountName FROM ‘LDAP://OU=CUI,DC=MyDC’ WHERE objectCategory=’Person’ And objectClass=’User’" 
Set objRecordSet = objCommand.Execute
or More fields:

Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("Name").Value + "," + objRecordSet.Fields("userPrincipalName").Value + "," + objRecordSet.Fields("sAMAccountName").Value

Keep farm and service account passwords written down. Once they’re in they’re in. you don’t want to have to reset them across the farm and app pools again.
But if you have to …..
Find the website in IIS.
Find the app pool user.
Set the new password in AD
Set the new password in the app pool. recycle app pool.
Set the new password for the account across sharepoint using:

stsadm -o updateaccountpassword -userlogin MyDomainController\svc_spssapp -password mypassword -noadmin
I run the above line on the web server, and the index server to make sure 🙂

Sometimes, when restoring a machine to a new domain controller, there’s the message:

Can’t connect to domain controller.
Even though you know the name is correct, to fix do the following:
 It’s a SIP issue. Remove the machine from the domain, – workgroup, then reboot, then add it again.


 Better debug messages:

 in the web.config file:
  <SafeMode CallStack="true">
  <customErrors mode="Off" />
  <compilation batch="true" debug="true">


If upgrade to sp1 gets stuck, this command sorted it out:
When upgrade got stuck at step 8, ran this : psconfig -cmd upgrade -inplace b2b -wait

content and config databases can be the wrong version for the farms wss, so to fix:
SELECT[VersionId] as VerConfig,[Version],[Id],[Updates],[Notes]
FROM SharePoint_Config.[dbo].[Versions]

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN>stsadm -o upgrade -inplace -url http://mybaseurl


Sharepoint – Can’t connect to configuration database.

Saw this one over and over, so many many causes.

1. Reset the farm password
stsadm -o updatefarmcredentials -userlogin MyDomainController\svc_spfarm -password farmpass -local

Still nothing, find out what the configdb is in the registry of the web server, and make sure that it can be connected to. Try making an ODBC source if you don’t have SQL Manager.

Ping to boxes.
Ping to box names as well as IPs.

Make sure that the app pool user/pass is correct and recycle it.
Can sometimes be caused by having a farm account with expired password.

Can’t list the Active Directory mapping fields on the Edit User Profile Property page.

Only seeing ‘Source Data Connection’ – Master Connection.

These messages where not that useful:

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 directory 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 attributes that are not normally accessible by users.

No matter what I tried, I could never get the little pull down to appear that would let me map my sharepoint fields to Active Directory fields.
I changed accounts, moved from AD – LDAP, tried AD resources, and got nothing!

Well, I never found a fix to this. But I did just write a patch to the DataServicePropMap table to have the fields mapped.

Insert into DataServicePropMap

Insert into DataServicePropMap
Values (20,1,’facsimileTelephoneNumber’,NULL,NULL,’True’)

19 means mobile, and 20 means fax. I got these values from:

playing with the following SQL

select * from PropertyListLoc

select * from DataServicePropMap
dbo.profile_GetDataServicePropMapping @DataServiceName=’redmond-ad’

The definitions of properties:
select * from dbo.PropertyList

SELECT  PropertyURI, DataType, Length, P.BlobType, DataServicePropName, AssociationName, P.PropertyName, P.IsMultivalue, DT.IsURL, DT.IsPerson, DT.IsEmail, DT.Name AS DataTypeName, D.DataSource
FROM DataServicePropMap D
INNER JOIN PropertyList P
ON D.PropertyID = P.PropertyID
ON P.DataTypeID = DT.DataTypeID
WHERE D.DataServiceID =
 ( SELECT DataServiceID FROM DataServiceList
  WHERE DataServicename = ‘redmond-ad’ )

(nb, redmond-ad was specific to my system )

I don’t know if there are hidden impacts to making this sort of change, but after weeks of trying to get things to map. The table changes were all I had left….
Get useful info from AD for import