Wednesday, September 8, 2010

redirect a page in a sharepoint form when user submits the form

The easy way to do this is to add to the URL the querystring ?Source=siteIWantToBeRedirectedWhenIClickSubmit. The link after the source is the link that users will be redirected when they click submit on the forms

Tuesday, September 7, 2010

JScript to check what classes are in use

Add this source code to a CEWP in same page and the mouseover will tell you what html class is in use:


Friday, August 13, 2010

How to create the JQueryMin feature

The Goal
This entry will show how to create the JQueryMin feature with a web scope so that if we activate this feature on a site (not on a site collection) the jQuery Minified JavaScript library (v 1.4.2) will be load in every page of the site and therefore jQuery can be used on those pages.

Pre-requisites
I have installed on the web server Visual Studio 2008 with the VSeWSS13 (visual studio extensions for SharePoint) v 1.3, and the MOSS SDK v 1.5. With this you should be able to use the WSP Builder within VS2008. If that is not the case, please download and install WSP Builder from Codeplex.

Do-it
In VS2008, create a new Project and choose WSP Builder





Your Project will have the structure below


Right click the project name and choose add > New Item…, then choose from the WSPBuilder Blank Feature. Name it, give the description and give the scope (Web) in this case.

Right click TEMPLATE and add 2 Folders: LAYOUTS and CONTROLTEMPLATES. This last FOLDER is to add a web user control using the approach of Jan Tielens in his blog entry “INTEGRATING SHAREPOINT 2007 AND JQUERY [PART ONE]
The Features folder we don’t touch for the moment. On the Layouts folder we create a new folder named the same way as the feature and inside that new folder we add the js file you can download from jQuery.com.

On the CONTROLTEMPLATES Folder we have to create a web user control. Because this project is a WSPBuilder project, this item is not available. So we need to create temporarily and to support this project a new project. Right click on the solution and choose under Web the ASP.NET Web Application template. Name it and add a new item. Choose the Web User Control template. Call it the same as your WSPBuilder Project. If you double click on the control, you will see its code. Delete the code and replace it with:


Remove the 2 files attached under the web user control and copy it to the CONTROLTEMPLATES on the other project.
Remove the temporary web project.

In the elements file inside the tag elements create a tag named control which should reference your web user control:



Then build the project by right clicking on the project name and choosing WSPBuilder and Build WSP:

If the Build succeed you will see a new wsp file with the project name on the same folder as your solution folder of VS 2008.

If you wish to deploy it straight to the server where you have you build the project, right click again and choose WSPBuilder > Deploy.

Then to use it, you need to activate the feature on the site you wish.

If it is on a different server, take the wsp file there, and run:

Stsadm.exe –o addsolution –filename Projectname.wsp
Stsadm.exe –o execadmsvcjobs
Stsadm.exe –o deploysolution –name projectname –immediate –allowgacdeployment –allowCasPolicies –force

Monday, July 26, 2010

Having different SSL sites on the same SharePoint front end server going through ISA server and forcing HTTPS in SharePoint environments

The goal: I had 4 different sites that I needed to SSL. Solution for ISA server was giving as many IP addresses on the server since IIS is only able to work out 1 SSL per IP (only 1 socket on 443). I also wanted to force SSL

The Solution: I create the 4 sites in SharePoint: ports 8000, 4444, 3333 and 5555. For each of these new web applications I enabled SSL in IIS (certificates later on). For each of these sites I’ve extended the web applications on port 80 with the desired host headers (portal.domainname.com; mysites.domainname.com, etc). On each of these sites on port 80, I would redirect (in IIS, on the Home Directory) the sites to the https site (which is the main sites on ports 8000, 4444, 3333 and 5555. On these sites on these ports (which are listening as well on port 443 as mentioned before), in IIS I check “require secure channel in the directory security tab. Now let’s deal with the certificates for this site.
The way to do it is to create the certificate and add to it the necessary “subject alternative Name” (please check MS KB931351). So, basically in one certificate you are adding https://portal.domainname.com, https://mysites.domainname.com, etc).
Then you have to configure the server Bindings for SSL Host Headers. To configure the secure bindings metabase property either use metabase explorer or type cscript.exe adsutil.vbs set /w3svc//SecureBindings “443:”. You have to repeat this for the 4 sites that are listening on port 443. One of the sites (portal p. ex) will not need it. This is the site where you will install the certificate. You do not need to install the certificate on all 4 SSL sites (though you need to make them listening on port 443 and have the metabase configured for securebindings.

The AAM are very simple: default will be https://portal.domainname.com to https://portal.domainname.com and the extended (internet p. ex) will be http://portal.domainname.com to http://portal.domainname.com.

What happens: what really happens is that you now have 4 sites all using SSL and running through 4 different ISA server rules but addressing them to the same server (I will write more on the ISA rules for this soon). The user places a request HTTP or HTTPS (it doesn’t matter) and the ISA receives it and sends it as an HTTPS request (why we forced HTTPS in IIS is because we can also access the site from inside where it does not go through the ISA server). Now the SharePoint server receives it and according AAM it sends the request to IIS as HTTPS (if internal, it could send as HTTP if the user so typed, but IIS will anyway internally redirect it to HTTPS, so it is the same effect). Because IIS only allows 1 SSL site on the IP address, that SSL site receives the request (in my case above, portal on port 8000 which is listening on SSL, has no metabase set for SecureBindings and has the certificate with the Subject Alternative Name attached). Check if the certificate matches the request (which will) and it then addresses to the 443 corresponding site (if the request was https://mysites.domainname.com it will address it to the site 3333 with the SecureBinding metabase equal to 443:mysites.domainname.com. The extension of this site on port 80 is only to redirect internal HTTP requests to HTTPS.
Hope it helps someone else.

Cheers,
GS

Thursday, July 8, 2010

check Kerberos Authentication

if you have in the Domain Controller in the System Event Viewer an Error with ID 11 and source KDC (which is logged if your Kerberos is not working and after you try to access the site from the DC) with something like DS_SERVICE_PRINCIPAL_NAME it means something is not working, use http://support.microsoft.com/kb/321044 with method 2 to solve it:

example:
C:\Documents and Settings\moss_sysadmin>ldifde -f check_SPN_MOSSDEVWFE.txt -t 32
68 -d "" -l servicePrincipalName -r "(servicePrincipalName=HTTP/MOSS-DEV-WFE*)"
-p subtree

where check_SPN_MOSSDEVWFE is the name you want to give the file and MOSS-DEV-WFE is the name of my Production server

Wednesday, July 7, 2010

add SPN entry for Kerberos SQL server authentication

SETSPN -A MSSQLSvc/.:1433

this is in case the instance is using the default port 1433.

to check what authentication a SQL connection is using, log on to your WFE and satrt the SQL Server Managemnet Studio (client tools), connect to the BE and place a new query:

select auth_scheme from sys.dm_exec_connections Where session_id=@@spid

Friday, February 5, 2010

Detect SQL servers on a domain

To find whether there is a connection to a SQL server and which SQL servers are available on the Network, type:

sqlcmd -L on the shell