Saturday, July 19, 2008

SharePoint user full name not reflected according to AD

Ok, first of all, this issue has nothing to do with user profile crawling. SharePoint seems to create some kind of user information store as of when a user first logs into the site collection. These information will not be updated when there are changes in the user’s AD user object, such as full name, department etc. Lots of people have this problem and blogged about it, but no real solution. I’m sure they have some kind of workaround but no one has posted it before.

Here’s my workaround. I’m sure MS does not support such actions, but we are desperate people (sometimes, at least). Run these SQL SELECT statements within your content DB, and you’ll know what to do next…

SELECT * FROM AllUserData WHERE tp_ContentType = 'Person'

SELECT * FROM UserInfo

SOME IMPORTANT ADVICE: 1)Backup your Content DB first before attempting any changes. 2) Experiment on your sandbox before making these changes permanent at your other actual environments. 3)You take responsibility on your own actions.

SharePoint Site column default value not pre-selected

After fiddling with SharePoint custom content types for a while, the default values on my choice site columns in my document library suddenly refuses to work. Although a default value is being set, the items are created with these field being blank, where it suppose to fill in with the defined choice default value, as stipulated in the content type’s site column.

Apparently, the content type has to be set as the document library’s default content type, else the choice column’s default values will not be pre-selected. In addition, if you have multiple content type that uses the same choice site column, setting any one of content type as default content type would make the other content type works too.

Ref: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1706972&SiteID=1

Unable to manage IIS 6.0 by using Server Manager if two threads access IIS 6.0 at the same time

I ran into this funny problem in the production environment recently. When launching IIS Manager (inetmgr) in the WFE servers, it shows the server, but it does not allow expanding of the tree to reveal the standard Web Sites, Web Application Pools sub trees.

A hot fix has to be applied to fix this problem. More info at MS KB946517.

Wednesday, July 16, 2008

Powerful AD Administrative Tools (FREEWARE!)

Found this great tool call Password Control for making bulk changes to user accounts in AD. (Thanks to a colleague for giving the tip!). Check out the feature set at http://www.wisesoft.co.uk/. Other than Password Control, there are other great freeware for making an AD admin’s life easier too!

Monday, July 14, 2008

Change AD Account Password via Coding

Found a few great articles on creating a custom page to allow user to change their AD login password through coding (cause I need to do one quickly here).

The new .NET Framework 3.5 provides new method from the System.DirectoryEntry.AccountManagement namespace to change password easily. Background information at here.

Steve Mushkat has a blog entry with code example on how this is done at http://glorix.blogspot.com/2007/10/ad-change-password-webpart.html. His example is base on SharePoint, but can be easily adapted for other flavours.

Update: I've tried the code on my SharePoint implementation. It worked fine on a single-box MOSS environment, but it didn't work on a small farm setup. Not sure why, but I'm suspecting the environment that didn't work did not have kerberos configured properly. I've modified the code slightly to make it workable:

string strADDomain = ConfigurationSettings.AppSettings["ChangePassword_Domain"]; string strADUser = ConfigurationSettings.AppSettings["ChangePassword_User"]; string strADPassword = ConfigurationSettings.AppSettings["ChangePassword_Password"]; string strLoginName = string.Empty; SPWeb web = SPControl.GetContextWeb(this.Context); strLoginName = web.CurrentUser.LoginName; PrincipalContext domainContext = new PrincipalContext(ContextType.Domain, strADDomain, strADUser, strADPassword); UserPrincipal user = UserPrincipal.FindByIdentity(domainContext, strLoginName); try { user.ChangePassword(this.txtOldPassword.Text, this.txtNewPassword.Text); this.lblMessage.Text = "Password changed. Please close this browser window and log back on with your new password."; } catch (Exception ex) { this.lblMessage.Text = String.Format("Password couldn't be changed due to restrictions: {0}", ex.Message); } finally { user.Dispose(); domainContext.Dispose(); }

Wednesday, July 2, 2008

SharePoint publishing timer jobs woes

I hit a problem where the content management’s scheduling feature were not working. I am able to set the start and end publishing dates, but there’s no changes when the time comes to publish/unpublish the pages. Apparently this is due to missing timer job definition for the particular web application that is hosting the particular site collection.

The job does not exist in the first place because the web application were created without creating the publishing/collaboration site collection from the GUI. Instead, I’ve added the restored content DB that was build on another SharePoint box and added it directly into the web application. If I were to create a publishing/collaboration site collection, the site provisioning process would have added the missing three jobs for content scheduling, and two more jobs for handling variations.

Therefore, to get the jobs back on the web application, I have to:

1. Create a new web application

2. Create a new site collection, choosing the correct site collection template (either publishing or collaboration)

3. Ensure the jobs are created by checking it from Central Admin à Operations à Timer jobs definitions. Also check whether it runs every minute.

4. Remove the content db of the newly created site collection

5. Add the restored content db

Additional observations: If the existing web application with the restored content database already missing the job definitions, removing the content database and creating a new publishing/collaboration site collection on top of it WOULD NOT solve the problem. Strangely, the job definitions are created, but it just wouldn’t execute as defined by the minute frequency. Thus, best bet is to delete the web application and start all over again.

Janne Mattila’s blog has more detail on this issue.

Update: I tried to make the same steps as mentioned above on another enviornment, and it didn't work. I even tried to schedule a publishing start date for a new content page on the brand new blank collaboration site template, just to be sure. The page on the blank collaboration site works, but it just wouldn't work once I restore my deployment content DB. I've inspected the timer job status and discovered that the timer job last run date/time was stopped at the instance when I change the web application's content DB to the deployment content DB.

Long story short, I found MS KB942989 mentioning the problem of missing timer jobs, but not on timer job stop executing. However, it indicates that a post-SP1 hot fix could fix the problem. I've downloaded, applied to all WFE and index server, and that solves the problem magically!

More information on the hot fix at MS KB942989.

SharePoint Current Number of Sites 0 after SQL Restore of Content DB

I was planning to restore a content DB backup into a SharePoint box. So I’ve created the web application, removes the default content database and add the restored content DB into the web application. Once this is done, the value “Current Number of Sites” is showing up as 0.

Apparently, when adding a content DB into a web application, the SiteIDs (GUIDs) in the content DB are added into the [SharePoint_Config].[SiteMap] table. If a site with the same SiteID already exist in the SharePoint box, the add process will fail without much feedback from the Central Admin page. The logs from the 12 hive doesn’t give much indication either. The only clue you get is from the application event log. An inspection on the event log shows the following error:

Therefore, must take note that no two identical site can reside within the same SharePoint box. There might be possible to patch the SiteID for the restored content DB to another GUID value, provided you know where to patch J.