Tuesday, June 14, 2011
Delete files from file system older then 30 days
forfiles /p "PATH" /s /d -30 /c "cmd /c del @file : date >= 30 days >NUL"
Then schedule a task to run daily at midnight.
Thursday, May 26, 2011
Signing an assembly in VS 2008
Wednesday, September 8, 2010
redirect a page in a sharepoint form when user submits the form
Tuesday, September 7, 2010
JScript to check what classes are in use
Friday, August 13, 2010
How to create the JQueryMin feature
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 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/
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