Thursday, March 23, 2006

WSS : Multiple Templates DocLib v2.0

I have fix the security issue when running as non-admin user in MultiTemplate DocLib and re-relase it as v2.0

http://workspaces.gotdotnet.com/jywss

Labels:

Wednesday, March 22, 2006

Security Issue with MultiTemplate DocLib

The reason for the pull back of v1.1 is that as I tested the doc lib with a non-admin user, an authentication problem arise.

My initial idea is to store all the local templates in the Forms folder. However, I found out that non-admin user will not be able to access files in the Forms folder. I found a workaround for this. I just create another folder(named documentTemplate) in the doc lib and store those templates in this folder. My code will then read all those templates from this folder.

As i continue testing, I found another security issue. When a non-admin user create a new document from a template stored in global template (under _layouts/documentTemplate), the user get a authentication dialog. Word, Excel and Powerpoint handle this differently. In Word and Excel, if you click Cancel in the dialog, the template that you select will still open. In Powerpoint, however, the template will not be open. This issue also happen in v1.0 which I have not tested with non-admin user.



I am still in the middle of finding out why there is an authentication dialog. Will update once I found the solution.

Labels:

Tuesday, March 21, 2006

WSS : Multiple Templates DocLib v1.1

Note : MultiTemplate DocLib v1.1 has been pulled back due to some issues run running as non-admin.


I have posted a new release of my Multiple Templates DocLib on GotDotNet workspace.

What is new is v1.1?
Added support to retrive document templates from the document library Forms folder.

http://workspaces.gotdotnet.com/jywss

Labels:

Thursday, March 02, 2006

WSS : Security Exception when Upload File using WSS SDK

I keep hitting an exception when I use the WSS SDK to upload a document to a document library in my WSS app. The error message read
The security validation for this page is invalid.
Click Back in your Web browser, refresh the page,
and try your operation again.


After some googling, the solution is you have to set the AllowUnsafeUpdates property of SPSite and SPWeb object to true before you upload the file. The code look like this:

using System.IO;

private void btnUpload_Click(object sender, System.EventArgs e)
{
string targetSite = "http://wssserver/sites/myteamsite";
string docLib = "my doc lib";
byte[] contents = null;

string saveAsFile = Path.GetFileName(FileUpload.PostedFile.FileName);
Stream stream = FileUpload.PostedFile.InputStream;

contents = new byte[(int)stream.Length];
stream.Read(contents, 0, (int)stream.Length);
stream.Close();

SPSite site = new SPSite(targetSite);
SPWeb web = site.OpenWeb();

site.AllowUnsafeUpdates = true;
web.AllowUnsafeUpdates = true;

SPFolder folder = web.Folders[docLib];

folder.Files.Add(saveAsFile, contents, true);

site.AllowUnsafeUpdates = false;
web.AllowUnsafeUpdates = false;

web.Close();
site.Close();
}

Labels:

Thursday, February 23, 2006

WSS Multiple Templates DocLib

I have created a WSS Document Library list definition that allow user to create a new document from one of the many templates in a drop down menu.


http://workspaces.gotdotnet.com/jywss

Labels:

Sunday, January 22, 2006

WSS Web Part Library Project Template for VS2005

I have created a WSS Web Part Library Project Template for Visual Studio 2005. It is
now published on GotDotNet. The URL is:

http://workspaces.gotdotnet.com/jywss

Labels:

Tuesday, December 06, 2005

WSS : Display document library in another WSS site (Caveat)

You can insert a Page Viewer Web Part into a WSS site that show the document library of another site by specifying the following URL for the Page Viewer Web Part:

http://[Server]/[Site Path]/_vti_bin/owssvr.dll?dialogview=FileOpen&location=DocLibName

Follow the link below to read about it.
How to display a single document library in another WSS site?

However, this does not work if your WSS site is created using the "Project Workspace" site definition. "Project Workspace"is a site definition which is added by Project Server 2003 when you install Project Server 2003.

You will notice the Page Viewer Web Part will flash the document library for a while and then it will turn to a blank page. If you View Source on the Web Part, the content is actually still there.

After some digging around, I found out it is cause by the JavaScript inserted by the "Project Workspace" definition.

If you look into Template\LAYOUTS\1033\PWAINC\CUSTOM.JS, it register the GlobalInit() function to be called on page load. Going into the function you will see the following code:


function GlobalInit()
{
try
{
if(window.parent != window)
{
bHostedinPWA = true;
}
}
catch(e)
{
bHostedinPWA = true;
}


Basically what it does is it check whether the page is loaded in the top level browser window. If not(EG: You load it inside a IFRAME), it will hide the contents(you can learn about this if you trace deeper into the code).

One workaround is to remove that checking in custom.js.

Labels:

Wednesday, July 20, 2005

Improving performance of the web part page gallery

If you find it can sometimes take 20 to 30 seconds to return the web part gallery so that you can drop a web part onto a web part page then this post is for you.

The problem may be because SharePoint is trying to contact the online web part gallery, however, if your machine is not connected to the internet, or the proxy is not configured properly, then it could take some time to actually work this out. This is the delay you are seeing.

You can easily turn off the web part gallery by following these simple steps:

1. Open SharePoint Central Administration (make sure you are on the Windows SharePoint Services page)

2. Click on "Configure Virtual Server"

3. Select the Virtual Server on which you are experiencing the delay

4. Click "Manage Security Settings for Web Part Pages"

5. Select the "Disabled" option next to "Online Web Part Gallery" and click OK.

Labels:

Friday, February 25, 2005

Saving documents to WSS site

If you want to make a MS Office documents available on the WSS site, there are 2 ways you can do it.

First is by goto the WSS site with your IE and upload the document.

The second way is easier and more interesting. While in your Word, Excel or Outlook, click the File Save/File Save As, and then in the FileName testbox, enter the URL to your WSS site(EG: http://wss_server/sitename, http://wss_server/sites/projectserver_xxx) and hit Enter. This will open a Window containing your WSS site. Navigate to your document library and save the document. However, this only work with Office 2003.

Labels:

Useful WSS site

I come across this site, WSS FAQ which has a lot of good stuff on Windows Sharepoint Services.

Labels: