8.19.2009

Runas in the machine don’t join domain

My laptop don’t join the company domain. Sometime I want to run a application as my domain account in the company domain to access the resource in the company domain, but the menu only existing “Run as administrator” when I right click the shortcut of the application.
How to resolve this?

There are two way I using to do Run As. One is ShellRunas v1.01, here is the detail description from Norm.

Another one is runas command in command prompt. Here is the syntax:

runas [{/profile|/noprofile}] [/env] [/netonly] [/smartcard] [/showtrustlevels] [/trustlevel] /user:UserAccountName program

It will easy to run the application as the account you have password.

If you encounter error by the command, please check do you accessed the machine by the account before first. That is because some program (as Visual Studio) running with account profile/env.

Change the connection string at runtime

I am doing a new project which try to utilize Quartz.Net to schedule the change of content base on Spring.Net and nHibernate.

The simple map is we have a regular process to deal with user’s request to change the content in the authoring environment and also input a schedule job into database by Quartz.Net. Another process, based on Windows Service will check the jobs queue, if the job startup time is up, then the process will update the content in the publish environment.

Seems the function is easy to implement. But we are frustrating for the timer job process to change database connection since the service module was based on Spring.Net and NHibernate.

After do some research and study, we finally found the solution to change connection string at runtime. (Beside this, actually there has another way to implement this function, by dual database provider).

This discussion thread detail the function implementation, and here is a great sample.

7.28.2009

About SPLimitedWebPartManager

Usually we add/update/delete web parts in the publishing page in MOSS 2007 by SPLimitedWebPartManager in object module. Most of the time, we got the test/demo small console program, then we implemented into QA/Staging/Production environment and got the expected result. But sometime not, and will confused us for a long time…

Recently, I am trying to add web part by object model, I choice the way to create web part instance and add the web part into PublishingPage by SPLimitedWebPartManager. The reason is the web part adding execute dll (thread) will called by the web part. So the only way to create new web part instance is by Reflection.

But I always got error message told me the page don’t check out? why? I run Page.Checkout() several time, and the web part adding was not work still. The error message is
The file is not checked out, You must first check out this document before making changes. at Microsoft.SharePoint.Library.SPRequestInternalClass.AddWebPart

After two weeks,  finally I got the hint in this discussion thread. Yes, the point is
PLEASE INITIAL SPLimitedWebPartManager AFTER Page Checkout.

7.24.2009

SharePoint June Cumulative Update Packages

Here is the announcement of Microsoft SharePoint Team Blog.

Build Number is 12.0.6510.5003.

Following are my note on this CU:

  1. The MSP_WEB_SP_QRY_ReadStatusApprovalHistory stored procedure takes a long time in some cases. – > Does this one meaning It will take a long time to process when we try to get the approval history?
    Beside this one is belong to MOSS 2007, others are for SharePoint Service 3.0.
  2. When a list is broken in your site, you cannot start a crawl successfully, and you receive the following error message in the crawler log:
    Crawling fails with "List does not exist" error Indexing and crawling failed with the following error: Crawling failed with an error for this URL: Error 0x81020026 The SharePoint list pointed to by this URL does not exist. Verify that it can be accessed using an internet browser. (List does not exist The page you selected contains a list that does not exist. It may have been deleted by another user.)
    However, you cannot delete the broken list by using the stsadm -o forcedeletelist -url http://servername:port/sites/sitename/listname command.
  3. SPList.GetItems(SPQuery) fails when the item count reaches the threshold value 2000, and you will receive the following error message:
    Exception occurred. (Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION))
  4. You configure a SharePoint server to accept incoming E-mail messages. You notice that incoming E-mail messages are processed based on their alphabetical order in the Drop folder. However, you want the incoming E-mail messages to be processed according to their order of creation in the Drop folder.
  5. Search query summary results are not rendered correctly when they contain Hexadecimal escaped characters. For example, a hexadecimal escaped character is displayed as "á".
  6. You have a SharePoint document library with the Major and Minor Version History option enabled. You also set the Only users who can edit items should see draft items option to "Who should see draft items in this document library?". If you use the "Get document" RPC method to download the drafts programmatically, it does not return the Draft Version.
    As a site administrator, when you use "Managed checked out files" to take ownership of documents checked out by other users in a Document Library that has 9 or more datetime columns, you receive the following message:
    Some of the files cannot be checked out by you. They have been deleted or checked in by other users.
    If you select more than one file to assume ownership, you notice that the operation succeeds only for the first file.
  7. You create immediate alerts and scheduled alerts on document libraries at the library level. You receive an initial E-mail indicates that a message alert is created. However, you cannot receive alerts for all the documents. This issue occurs in Contributor and Reader when major and minor versioning is enabled on the document library.
  8. You install the Hotfix package described in KB 968850. However, when you click Site Action in a SharePoint site, the menu in the Site Action is expanded to the same width as the Web page.
  9. You can display pictures from E-mail messages in an E-mail enabled "Discussion board". However, if users reply to your E-mail and insert pictures, the pictures from the replied E-mail message are displayed as "X" in the Discussion Board.
  10. Incremental content deployment from a source Microsoft Office SharePoint Sever (MOSS) 2007 farm to a target MOSS 2007 farm fails intermittently with SQL deadlock errors.
  11. In SharePoint document libraries that have versioning enabled, if you upload a new document and enter text in the Version Comments text box, the text you entered in the Version Comments text box will be lost, and will not be visible when you view the version history of the document.
    In the issue tracking list, you can open and save an attachment successfully for the first time, but when you try to save the attachment again, you receive the following error message:
    The Internet Address <URL> is not valid.
    About this one, the good thing is I never suggested user to use this list template.
  12. You use multi-value lookup values in a SharePoint list. However, you notice that some documents in the SharePoint list are unpublished. The multiple value lookup values in the AllUserDataJunctions table are still present and flagged as current version documents and are not marked to be deleted. Therefore, multiple value lookup values become orphans. In this case, if you use the stsadm -o export command, the export phase of the content deployment will fail.
    NOTED: LOOKUP COLUMN MAYBE CAUSED THE EXPORT FAILED IN PRE-VISION.
  13. When you edit a detached page in the pages library and then click Modify Shared Web Part, you are redirected to a "This page has been modified since you opened it" page.
    I think this error message was familiar for any SharePoint admin. m….maybe I have to check does this error message will popup again when I modified the navigation.
  14. You experience poor performance when you use the stsadm -o export command to export large sites.
    If possible, maybe some benchmark will help SharePoint admin more.
  15. If you rename a .doc file in the Document Library, the custom non-text properties of the .doc file change to a text type and lose their values. The custom properties are only created in the .doc file and there are no custom columns for the properties in the Document Library.
  16. When a SharePoint user creates a circular loop between lookup columns, if you click one of the lists that contain lookup columns, this action will cause 100% CPU usage on the SharePoint server. To work around this issue, you have to perform an application pool recycle.
    Ah…Ever loop, maybe add a condition check and popup a warning will be more help…whatever SharePoint was for the common user, right?
  17. When you restore a host header site collection from a backup to a new host header site collection, the host header value in the restored site collection is still the host header of the old site. After you restore the site collection, if you detach and reattach the content database of the restored site collection, the restored site collection is no longer available and will be left orphan.
  18. You use the Group By option in the People and Groups list, and then you set the group to "Collapsed by default". However, when you try to expand the group, it cannot be expanded.
  19. You move a sub-site to a new location, and then you delete its earlier parent site. In this case, the incremental deployment job fails, and your receive the following error message:
    Error deleting Web site "/ParentSite/SubSite". You can't delete a site that has subsites.
    You use a computer that is running Windows Vista in a domain that has an "&" in its NetBIOS domain name. When you try to use this computer to checkin a document into a SharePoint document, you receive the following error message:
    This document was checked out to your local drafts folder but the local copy could not be checked in to the site. Close any application that is editing the document and try to check in again, or discard the checkout.
  20. When you try to upload a .mht file generated by a third-party application to a SharePoint document library, you receive the following error message:
    No "boundary" in CGI environment.
    Troubleshoot issues with Windows SharePoint Services.
  21. Workflows do not recognize users from the Membership Provider in the SharePoint Designer when Forms-based Authentication (FBA) is enabled.
  22. You have a SharePoint list that has more than 500 items. The list has a column of "People and Groups" type with the "Allow multiple selections" setting set to "Yes". If you click Show Filter Choices in this list, you receive the following error message:
    #RENDER FAILED
  23. In an extranet deployment scenario in SharePoint, the URLs to access SharePoint internally and the URLs to access SharePoint externally are different. You access the SharePoint externally, you visit a page that contains a list view Web part, you edit the list view Web part, and then you click the Edit current view link. However, when you click Cancel to go back to the previous page, you receive a "file not found" error message. Additionally, when you examine the URL in the Internet Explorer address bar, it displays an internal URL.
  24. When you are using reusable content and perform a content deployment, only one version of the reusable content is preserved on the target site. It will always be the latest version on the source site regardless of whether the latest version is approved or not.

4.15.2009

The EventHandler Can't Update Item Data

This story has two part, one is SPItem, another is update failure.
When we update the SPItem property (Field Value) in EventHandler, we know we have to update the data in the event ItemUpdated and not in ItemUpdating. I believe it is easy to find the reference in the www.

We also know we can't utilize the parameter value directly in the ItemUpdated function, we have to initial different instance from new SPSite, SPWeb by the information from patameter, and then we can utilize SPSecurity.RunWithElevatedPrivileges. But in this case, we also have to update property in the difference instance. Why? basically that just my experiences, sometimes the parameter instance will be null when the event handler triggered. Why said sometime? That's also I wonder to understand, in the many many test, I can't figure out why sometime the parameter instance is null. If anyone know the RC, please kindly enlighten me.

But even those, sometimes the instance created by us also be null. Why? I guess that is the latency of the event handler. The following is what I do for it:
SPListItem temp = null;
while (temp == null) {
Thread.Sleep(500);
temp = properties.OpenWeb().Lists[properties.ListId].Folders.GetItemById(properties.ListItemId);
}
Yes, I just sleep the thread..

This really resolve my case for half year, but before couple days, this trick don't work.
After check with MSDN, Here is the Final version.


RETRY2:
int retrycount = 0;
try {
SPListItem temp = null;
while (temp == null) {
Thread.Sleep(500);
temp = properties.OpenWeb().Lists[properties.ListId].Folders.GetItemById(properties.ListItemId);
}
temp[_TSSDocumentFieldName] = url;
temp.Update();

//UPDATE.....
} catch (Exception ex) {
retrycount += 1;
if (retrycount <= 5) {
System.Threading.Thread.Sleep(2500);
goto RETRY2;
} else {
debug.Append("[EXCEPTION][UPDATE PATH 2]" + ex.ToString());
throw ex;
}
} finally {
this.EnableEventFiring();
}
}
}

mm.....actually I am shocked when I saw the sample code in MSDN document.

3.21.2009

How we can add comment into folder in the document library of SharePoint

The document library in SharePoint 2007 is good for sharing information, but sometimes people want to add some comments into the folder. How to do it?

It’s very easy to do it by configuration. First, we have to define a new Content Type which inherit from folder type. And then we can change the document library to be able to contain multiple content type, and add the new content type we just created into the document library.

So, here is the steps:

Click Site Action –> Modify All Site Settings into the Site Setting Page.

Click Site content types which under Galleries column.

Click Create in the Site Content Type Gallery.

Key in Name and Description, Select Folder Content Types as parent content type group and select Folder as parent content type.
Note: The content in the description will be shown as image below, after all steps are completed.


After the content type is created, we can go back to the document library, and click Settings –> Document Library Settings. And select Advanced Settings under General Settings column.


Change Allow management of content types? to be Yes, and change Display “New Folder” command on the new menu? to be No.

Go back to the document library settings page and click Add from existing site content type.

Add the content type that we just created.

Now we have two content types in this document library, and then we have to create the comment column for the folder content type. Click Add from existing site column in the Columns section. Add the column called Comments, uncheck “Add to all content type”.
After the new column is added, we also have to add the column into the content type. Click the content type we just created, in this case, it’s “New Folder Type”. Click Add from existing site or list columns, select columns from List Columns and add the column we just added.
Now, it’s done, we can try a new “Folder Content Type” and edit the property “Comments”.


Change the content type to “New Folder Type”

Then you can comment your folder

1.13.2009

About PropertiesBag

最近都在忙有關MOSS的開發, 遇到一個狀況. 就是說當我開發一些SharePoint上面的應用程式時 當然會遇到要儲存資料的狀況. 一般來說 我們會把資料盡量放在SharePoint的List中. 但是如果是一些Configuration呢?

因為大部分是簡單的資料, 所以後來的做法是放到Web Site的PropertiesBag, 單純的Key Value Pair, 相對很方便.

不過後來就是因為這個所以有痛到, 因為系統有跑Content Deployment, 所以會把資料從開發環境送到正式環境. 是的, 正如你想像, PropertiesBag會蓋過去. 這下子就死定了.

所以這告訴我們, 當有Content Deployment時, 很多東西的處理上要改變一下.

 

Recently I am busy with some application development on SharePoint. Here is a usual case for the development, there always have some data have to stored, most of them are simple value, as configuration.

In the first, we stored it in SharePoint List or PropertiesBag.Seems good, right? Everything is good until deploy to another server farm. The propertiesBag will copy in content deployment! oh….My database connection, web site id…etc….

This is the lesson, we must change the view when we are utilize SharePoint content deployment