sharepointdevelopment

Saturday, September 23, 2006

How do I get my ASP Application to run in a WSS site?

This Tutorial is courtesy of Michael Greth. You'll find the original German language version with three useful images at http://weblogs.mysharepoint.de/mgreth/articles/471.aspx

(The translation here is mine.)

Note: In this example the ASP application is to be accessible via http://office/asp where http://office is the address of the WSS site.

1. Access the WSS server and create a new sub-directory (asp) under the WSS Site (example e:\webroot\office)

2. Copy the ASP files to this sub-directory (e:\webroot\office\asp)

3. Access Programs / Administrative Tools / SharePoint Central Administration

4. Select 'Configure virtual server settings in the "Virtual Server Configuration" section of the page.

5. Select a virtual server (default "Default Web Site").

6. Select "Define managed paths" in the "Virtual Server Management" section of the page.

7. In the "Add a New Path" section at the bottom of the path do two things

a) add /asp to the Path box

b) select the "excluded path" radio button.

8. OK

After doing the above the path will no longer be administered by WSS and the ASP application will run.

Tutorials

http://wss.collutions.com/pages/VI%20-%20Tutorials.aspx

WSS FAQs

http://wss.collutions.com/Documents/FAQ25.pdf

SharePoint Portal Server 2003 FAQ

SharePoint Portal Server 2003 FAQ

This topic compiles and provides answers to questions frequently asked by our internal and external customers. This is by no means a complete list of the questions our customers ask for. If you don't see what you're looking for, let us know at SharePoint MSDN Developer Feedback.

Note: Be sure to review the Microsoft Office SharePoint Portal Server and Microsoft Windows SharePoint Services FAQs at GotDotNet. Tips and Tricks for Using Microsoft Office SharePoint Portal Server 2003 is also a great resource for developers who create Microsoft Content Management Server Web sites and need to customize the Web Author to meet the business needs of the content contributors.


Top Questions
Can I modify the SharePoint databases directly?

SharePoint Products and Technologies do not support direct access to the databases. Modifying the databases directly can break SharePoint Products and Technologies and can break upgrade to future versions as well; you should use the object model and/or Web services instead.

How do I use the Windows SharePoint Services and SharePoint Portal Server object models together on a single application?

You can access the Windows SharePoint Services object model from the SharePoint Portal Server objects. Just set references to the required DLLs—both Windows SharePoint Services and SharePoint Portal Server—and you should be able to use both the object models in your application.

General - Getting Started

What is the advantage of building a Call Center as a SharePoint Portal Server application versus as a Microsoft ASP.NET solution?

SharePoint Portal Server allows you to create pages with independent Web Parts. You can quickly and easily reapply the same Web Parts in any number of new SharePoint Portal Server applications within the organization. For example, if a special VIP lounge application were created, much of the Call Center application could be retasked to expose customer trends and membership history to the Customer Relationship Representatives to help them decide how to best serve the VIP guests.

In addition, each person on the Call Center could have their own personal page that listed open tickets, targeted information and links, and so on. With SharePoint Portal Server 2003, integrated people search would make it easy to find other individuals to help with difficult calls. Microsoft Single Sign-On service would make it easier to connect to back-end systems.

Can I develop applications using the SharePoint Portal Server object model from a Microsoft Windows XP-based computer?

Yes. Just copy the necessary SharePoint Portal Server DLLs from a SharePoint Portal Server computer and point to the DLLs when you add a reference in your development project.

Note: The application you develop using this method still needs to run on a SharePoint Portal Server only. You cannot access the SharePoint object model remotely; you can access it only from applications running on the physical computer where SharePoint Portal Server is installed. If you want to access a remote computer, you need to use Web services, and may potentially have to write your own Web service.


How I can host ASP or ASP.NET pages in a SharePoint site?

Active Server Pages (ASP) pages hosted in a SharePoint site go through the SharePoint Internet Server Application API (ISAPI) filter, which does not parse ASP. Therefore, you will only get the raw source of the file if you attempt to browse to it.

In contrast, you could set up an exclusion on your virtual server that is extended with Windows SharePoint Services and put your ASP pages in that exclusion. Then you can turn on the Internet Information Services (IIS) ASP filter and have it parse those pages.

What is the best place to set properties in an ASP.NET Web application?

You should not set properties in RenderWebPart(). ASP.NET does not support changing property values after OnPreRender() is called. In general, set properties in the Load() event handler. OnPreRender() can even be too late for tool pane events.

I'm having problems running a form from a computer that isn't running SharePoint Portal Server. Please help.

Any form that updates information should run on a SharePoint Portal Server computer; this allows you to use the object model to set AllowUnsafeUpdates to true (SPWeb.AllowUnsafeUpdates). If you run a form from a computer that isn't running SharePoint Portal Server, it has the same effect as turning off Security Validation. Your form should be an application running within Windows SharePoint Services or SharePoint Portal Server in the _layouts folder, for instance, and should just be accessed from other client computers. You do have the option of turning off Security Validation if you need your form to run from another computer. However, this is not recommended.

I want to rename a team site from http://portalname/sites/testsite to http://portalname/sites/teamsite. I'm a site admin, but not a site collection admin. How can I accomplish this?

You cannot rename the root of a site collection, in this case, testsite to teamsite. You can however, rename the subsites using Microsoft Office FrontPage 2003. To rename the root of a site, you have to request this from the server administrator and ask him or her to back up this site using STSADM, and then restore it back as whatever name you want, such as http://portalname/sites/teamsite.


Security, Authentication, and Active Directory

I'm getting a "System.Security.Permissions.SecurityPermission" exception when I try to impersonate a Windows user account in my code. I'm trying to use the LogonUser() method and the WindowsIdentity class.

The LogonUser() method requires FullTrust. This method cannot be called by a partially trusted assembly. For more information on code access security, see .NET Support and Security in Microsoft Windows SharePoint Services.

I have problems using FormDigest authentication. It does not work.

FormDigest authentication will only work within the context of the site that is being called or referenced. FormDigest authentication will not work unless the POST is made from within the site context (for example, if the application is running in the _layouts folder of a specified site on the server where the requested site is physically installed).

I'm getting the "COM object with CLSID {BDEADEBD-C265-11D0-BCED-00A0C90Ab50F} is either not valid or registered" error when using a Sharepoint:FormDigest object on my ASPX page. What should I do?

If you get the error "COM object with CLSID {BDEADEBD-C265-11D0-BCED-00A0C90Ab50F} is either not valid or registered" when using a Sharepoint:FormDigest object on your ASPX page, you should not have a Sharepoint:FormDigest object on the page because Security Validation is going to be *off* on the target server. Additionally, you should remove the Register directive, which registers Microsoft.SharePoint.WebControls, and remove the OnSubmit attribute from the form.

Why does SharePoint Portal Server, even though it is an ASP.NET application, still look at the LOGON_USER server variable and not the HTTPCONTEXT.User?

Even though SharePoint Portal Server is an ASP.NET application , the piece which deals with IIS or the SharePoint Portal Server ISAPI filter is still unmanaged and does not understand HTTPContext.

I'm getting an error in a Web Part that allows users to change their Active Directory passwords. I'm using SetPassword() in my Web Part to change the password.

You should modify your application to use a call to ChangePassword() rather than SetPassword(). The latter must run in the context of a domain administrator, because it does not require the current password to make a change. The former takes the current password and the new password as parameters and is able to verify that the user requesting the change has the right to make it. Following is the signature for this method:


HRESULT ChangePassword(BSTR bstrOldPassword, BSTR bstrNewPassword);


So, you'll need to modify your code and sample to take the old password and the new password, and then call ChangePassword as opposed to SetPassword.

A user with Manage Personal Views permission is unable to add views programmatically. Why is that?

The bad news is that adding the "Manage Personal Views" permissions to the Reader role does not enable the user to add the personal view programmatically. This is a bug, because the same action is allowed through the user interface. However, there is a workaround and here are the steps:

Impersonate as Admin
Add user to Web Designer role
Undo Impersonation
Create personal view under user
Impersonate as Admin
Remove user from Web Designer role
Undo Impersonation
Using the Webs property throws an error. Please help.

You cannot access the Webs property if the user is not authenticated. Use the GetSubwebsForCurrentUser() method instead of the Webs property, which gives all the Web sites for the current user.

I'm getting an error when moving the class file containing the custom server control to a separate project/assembly (CustomControls). Please help me troubleshoot.

If you are using a custom trust level, please change it to FullTrust. Also, you need to add the "Assembly: AllowPartiallyTrustedCallers" bit to AssemblyInfo.

There is a method on the SPWeb object called GetSubwebsforCurrentUser that gets all of the subsites for the current user. Unfortunately, in the current application design of SharePoint Portal Server, this does not take into account the sites created under the c1, c2, etc. folders that the portal sites are created under. Are you aware of this limitation, and any ways to work around it to get the Web sites that exist within those parts of the portal site?

There is a workaround for this problem. Set the CatchAccessDeniedException to false to avoid the prompt and instead get an exception. Change the code to create an array of URLs instead of Web sites and then create an SPWeb object in the context of the current user.


Customization

I want to remove the links (My Site, Settings, Help) at the top. How can this be done for everyone but the Administrators?

For the My Site and Settings link to disappear, you need to give minimum rights to your Authenticated Users.

About the search component…how can I add values to the drop-down list of the search box so that I can reduce the search scope?

To limit the search scope, define your search scope in http:///_layouts/1033/listsearchscopes.aspx after defining your content sources in http:///_layouts/1033/ListContentSources.aspx.

How do I hide a Web Part?

Currently, you cannot hide a Web Part. However, you can set the Web Part Frame Style to None, which may accomplish what you need.

How do I remove access for non-administrators to Restore Documents programmatically?
You can add a check before displaying every link to the user, whether the user is an administrator or not. Following is the check:

if SPControl.GetContextWeb(Context).Permissions.DoesUserHavePermissions((SPRights)SPPermissionGroup.Administrator)== true)

Where do I view or set the antivirus settings?

Antivirus settings are stored as a part of Global configuration. You should be able to set or get them using the SPGlobalConfig object and Properties collection. A sample is available for that task on MSDN.

Following is the information from the SharePoint Portal Server 2003 Administrator's guide on what properties you can set or get:

Antivirus Properties: Use these properties to configure antivirus protection for your server. Specify whether users can download infected files to their client computers, whether antivirus cleaning is enabled, whether the download and upload scans are enabled, what the timeout time is for scanning, and the number of threads to take up with antivirus processes. For more information about using antivirus scanning, see Configuring Antivirus Protection.

Property Name Value
avallowdownload yes/no
avcleaningenabled yes/no
avdownloadscanenabled yes/no
avnumberofthreads A numerical value, the number of threads to use.
avtimeout . A numerical value, in seconds
avuploadscanenabled yes/no




Search
I'm confused about search in Windows SharePoint Services and SharePoint Portal Server. How is search implemented? What are the ways to customize search?

Search in Windows SharePoint Services

The Windows Sharepoint Services object model (OM) allows interaction with the various data and processes that Windows Sharepoint Services provides. The Windows SharePoint Services OM provides you with two means of searching right out of the box: SearchListItems and SearchDocuments of the SPWeb class. Both of these methods (as the Microsoft SharePoint Products and Technologies SDK states), work by using the Microsoft SQL Server Full-Text search function. SearchListItems will search in a list; SearchDocuments will search in a document library. Both will return a Search Result collection.

However, what Windows SharePoint Services provides is extremely fixed and limited. You cannot plug in a lot of Boolean expressions for the search criteria, and there is no way to perform simple AND operations between keywords (it is OR by default).

Search in SharePoint Portal Server

Search.aspx is the search page built into SharePoint Portal Server that can be fed a string of criteria to be processed. This saves you the effort of writing complex MSSQLFT queries for the methods stated earlier. A simple example would be executing the statement Search.aspx?k=performance. This will run the query, and render the results on the page. This is perfect if you don't want to render the results yourself, and you don't have any special requirements for the way the data is presented to the user.

In addition, SharePoint Portal Server 2003 provides a very flexible way of searching through the use of MSSQLFT queries piped through to SQL Server.

The QueryProvider object gives you a means of locally executing a search on the server, and returning the results for you to manipulate and render in the way you want. The QueryProvider object needs to be given the portal-level context and not site level. If you pass in the site-level context, you will receive an "Object reference not set to the instance of an object" exception.

The Query Web Service does exactly what QueryProvider does, except it exposes the methods over the network. You can run searches remotely by connecting to the Web service located on your SharePoint Portal Server computer. The results will then be fed back over the wire as either a dataset or as XML.

When calling the QueryEx or Query method on the Query Web service, I get an "Object reference not set to the instance of an object" exception. Why is that?

The QueryProvider object must point to and run under the context of the portal site (http://myportal) so that it can reference its search.asmx under the _vti_bin of the portal site. Because it is a portal-wide search, it uses the search.asmx file at portal level. Therefore, you should reference the search.asmx in this location when you set a Web reference: http://myportal/_vti_bin/search.asmx. Pointing to the search.asmx in any other location will result in the "Object reference not set to the instance of an object" exception.

When creating the QueryProvider object in my Web Part, I get an "Object reference not set to the instance of an object" exception. Why is that?

The QueryProvider object must point to and run under the context of the portal site (http://myportal). Therefore, you need to give the QueryProvider object the portal-level context and not the site-level context. Instead of giving it the GUID of the site where your Web Part is located, try giving it the GUID of the portal site itself. If you pass in the site-level context, you will receive an "Object reference not set to the instance of an object" exception.

SharePoint Object Model Maps for Download[PDF]

http://blogs.msdn.com/andrew_may/archive/2006/05/31/SharePointBeta2ObjectModelMapsDownloads.aspx

SharePoint Web Part Deployment & Security FAQ

http://store.bamboosolutions.com/productspecs/SharePoint%20WP-CAS%20FAQ.pdf

Wednesday, September 06, 2006

Web Part Development