Sunday, July 23, 2006

Gone for the next three weeks!

Tomorrow I'll leave really early in the morning with my girlfriend, heading to Norway with our car. We'll be touring through Norway the next couple of weeks :) Wish us fun and see ya back again somewhere in august!

Thursday, July 20, 2006

Mysterious Obfuscated List Views

From a new sharepoint blogger on the block :

All lists have a set of supporting files for the Display Item Form, the Add Item Form and the Edit Item Form This means you can obfuscate your list by creating your own page with a dataview, and then whenever a user clicks a link to your list, they go directly to your web part page instead. Make sure you remember the original url so you can still edit your list!

Tuesday, July 18, 2006

To allow updates on a GET, set the 'AllowUnsafeUpdates' property on SPWeb

UPDATE 20/7/2007 : From Gary comes this solution :

There is a way to accomplish this on a GET method. What you need to be sure to do is after executing the web.AllowUnsafeUpdates = true, you need to execute web.Update() or it doesn't get committed. I used that with no problems. Also, be sure to set the property back to false when you're done with it.
Yeah that's right.. I spend hours and hours today figuring that one out. Let me begin by describing the context what I was trying to achieve. I'm currently busy with creating a webpart that creates a site beneath a portal (/sites/teamsite) by using information coming from a list. So the first thing to achieve was adding a site programmatically using the object model. In the SDK I found two solutions to achieve this: 1. Using the SPWebCollection.Add method 2. Using the SPSiteCollection.Add method. Now, to my believes a site beneath a portal (thus : portal/sites/teamsite), is a sitecollection. So I went for solution 1 ;) (SPWebCollection.Add method can be used to create subsites within a sitecollection) So my code looked like this :
protected override void RenderWebPart(HtmlTextWriter output) { try { SPGlobalAdmin globalAdmin = new SPGlobalAdmin(); SPSiteCollection siteCollections = globalAdmin.VirtualServers[0].Sites; SPSite newSiteCollection = siteCollections.Add("sites/requestsite", "RequestSite", "RequestSite", 1033, "MPS#5", "myusername", "Robin", "myemailaddress"); } catch (Exception error) {output.write(error.Message.ToString();} }
This didn't work because I got the following error: "Updates are currently disallowed on GET requests. To allow updates on a GET, set the 'AllowUnsafeUpdates' property on SPWeb" So I added the following line:
globalAdmin.AllowUnsafeUpdates = true;
And yet I was still receiving the error so I turned to my favorite friend Google! There I found a lot of users dealing with the same problem as me. But as my search was progressing I stumbled upon : Eric Lim's Things to note: SharePoint AllowUnsafeUpdates Eric had the same problem but had a smart colleague who pointed out that the code must be executed in a postback. Using this knowledge, I created a simple button and moved the code from the RenderWebpart method to the Button.Click method, compiled it, ran stsadm -addwppack for the millionth time, opened the page where the webpart was located.. and .. yes it worked! :) Thanks Eric!

Which BDC tool should I use?

Also from Bill :

I was a little confused (as I often am) earlier today as I noticed Todd Baginski has put together a tool he called the “MOSS BDC MetaData Manager”. Catchy name but didn’t I just hear this tune? There’s a CodePlex project underway called the “Database Metadata Generator for the Business Data Catalog”. Okay, not as catchy but isn’t this essentially the same tool? Not quite. Todd explains he looked at the project on CodePlex and there are differences between his tool and that one. Botton line, get Todd’s tool and you’ll be good to go, creating application definitions at the flick of a mouse. If you haven’t figured out what the BDC is all about and what it can do, please dive in (a good starter is here).
Read the whole story here

Sharepoint Knowledge Base Webpart

Well Bill has found some spare time to write another great webpart (although it's not available for download yet, so maybe he just photoshopped the whole thing together) with the following functionality :

- Ability to add as many questions as you like - Ability to add and categorize questions into categories (including multiple categories for a single question) - Search capabilities to find questions and answers - Rating for each question (was this helpful - yes/no) - Add comments for each question - Moderation of questions (or you can leave it open so questions are published immediately) - View questions by category (with number of questions displayed) - Quickly jump to any category instantly from the main page - Assign related questions to other questions - Attach any number of files to a question
And for some screens :

Friday, July 14, 2006

Setting up and Publishing to Excel Services Step By Step

Jason Medero wrote an article about 'How to setup Excel Services in MOSS 2007'

MOSS 2007 Customization: Content Types, Columns and Page Layouts Explained

Shane is at is again! ;) Check his post about :

Staying true to my “designer” root, this article outlines some of the MOSS 2007 terminology, and how they relate to a “regular website”. In the end you should have a slightly better idea on how to leverage the power of MOSS 2007 to create robust and fully customized web applications.

Definitive CSS guide of 2003?

Heather posted her 'trusty SharePoint 2003 CSS Reference guide' ;) Go check it out I say!

For popular CSS styles, it includes: - Portal/WSS specification - Class/ID name - Descriptive function in site - SPS.css and OWS.css line number and general properties - Screenshot

Friday, July 07, 2006

Survey export to excel problems

Ok so what do when you have the following error : 'Sharepoint "Results to spreadsheet" results in Error: Unable to open ........ The Internet site reports that the item you requested could not be found. (HTTP/1.0 404)' Check whether the user is accessing the site via an anonymous + windows intergrated authentication or just pure windows integrated. Excel tries to access the site anonymously and therefore cannot open the survey. The case which I had this problem was one where we have a portal with teamsites both accessible as anonymous as windows intergrated. We use two urls for this scenario since Sharepoint Portal does not come with a sign-in button so defaultwise this url is only windows integrated. The other url is both windows intergrated and anonymous. Most users use this url to access their site and therefore had this problem. I had a hard time figuring this one out! :)

2007 New online training content available

Well it seems that Microsoft (especially Lawrence Lui) is really pushing the envelope by giving us developers so much information/hand's on experience so early in the phase of Sharepoint 2007!

Our User Assistance Group continues to crank out more and more online training content. Here are the latest additions: Developer Clinics: Clinic 5046: Inside Look at Building and Developing Solutions with Microsoft Office SharePoint Server 2007 Clinic 5045: Inside Look at Developing with Microsoft Windows SharePoint Services 3.0 MOSS 2007 Hands-on Labs: Office SharePoint Server 2007 Functional and Architectural Overview Virtual Lab Enterprise Content Management with Office SharePoint Server 2007 Virtual Lab Organizing and Finding Resources with Office SharePoint Server 2007 Virtual Lab Business Solutions Using Office SharePoint Server 2007 Virtual Lab WSS V3 Hands-on Labs: Introduction to Windows SharePoint Services 3.0 Virtual Lab Implementing and Administering Windows SharePoint Services 3.0 Virtual Lab

SharePoint Learning Kit now available on CodePlex

Again from the Simser ;)

SharePoint Learning Kit now available on CodePlex CodePlex just keeps getting groovier and grooview with SharePoint projects. Here's the latest. It's the SharePoint Learning Kit and the first Community Technology Preview (CTP) is available for you to download. For those of you familiar with Class Server, this is the same thing. For those that are not familiar with it here's the blurb from the site: SharePoint Learning Kit (SLK) is a SCORM 2004-conformant e-learning delivery and tracking application built as a SharePoint v3 solution. It works with either Windows SharePoint Services 2007 or SharePoint Portal Server 2007, and has the following core features:
  • Supports SCORM 1.2, SCORM 2004, and Class Server content, allowing users to store and manage this content in SharePoint document libraries.
  • Supports a learner-centric or instructor-led (assigned) workflow.
  • Allows assignment, tracking and grading of both e-learning and non-e-learning content.
In this CTP you can install and configure the SLK Solution and use it to assign SCORM 2004 content on a SharePoint site. Learners can view a list of their assignments with the assignment list web part, and can interact with the assigned content. The learner's interactions are stored in the SLK database. This CTP also has SDK and source code downloads for developers to review SLK and the underlying Microsoft Learning Components (MLC) API to determine whether it might be suitable for their applications. Very cool stuff. You can check it out here on it's new CodePlex home.

Thursday, July 06, 2006

SharePoint Forums 1.1 Released

Bil Simser has been a busy man but found tim to release an update for his Sharepoint forums webpart! Download version 1.1 right here! Example : Bloody brilliant! ;)

Wednesday, July 05, 2006

WSS2 WebParts compiled with framework 1.1 on VS2005

From Steen Molberg :

In the past I have stumbled over this post from Carlos Segura Sanz, who created a WSS2 F1.1 WebPart Project Template for VS2005. Great work! I used the information from this post to find out how I could move my VS2003 projects to the VS2005-platform. I puzzled around a bit with this and it turned out to be quite simple, so I thought I post the steps here for your convenience..
Check his blog for the steps ;)

MOSS 2007 Upgrade Error

Matthew Cosier's Blog: MOSS 2007 Upgrade Error Matthew posted a walkthrough in case you run into the "failed to start the database service MSSQL$OfficeServers. Repair this product using Add/Remove Programs”- error, what happened to me also btw. So thanks Matthew! ;)

Orphaned Sites

From Keith's blog :

An Orphaned Site is where SharePoint only has partial information and not a complete set of data for a given site collection in your Windows SharePoint Services or SharePoint Portal Server content databases or configuration databases. The site may in fact still be viewable via the browser, but you may notice that many things are broken. 99% of the cases I have seen though, the orphaned site is just unavailable. More information about orphaned sites: Orphaned Sites - Part 1 Orphaned Sites - Part 2
So the news is that the STSADM tool has been extended with new parameters to fix there sites ;)
Finally, the Orphan Repair extensions to STSADM are complete: For WSS Alone: Description of a new command-line operation that you can use to repair content databases in Windows SharePoint Services;EN-US;918744 If you have a SharePoint Portal Server 2003 environment, you may also need the following: Description of a new command-line operation that is available for the Spsadm.exe command line tool that you can use to clean up orphaned items in the configuration database in SharePoint Portal Server 2003;EN-US;918742

Tuesday, July 04, 2006

Password Reminder

Ok, what happens when you have a Sharepoint extranet environment? Right! Users don't get prompted or reminded that they have to change their password within a couple of days. So there are several solutions to overcome this problem: 1. Create a console application that is scheduled to run every day to check if an user's password is about to expire. If expiration is due, for example, 10 days. An email is sent to the user which will remind the user to change their password. 2. Create a webpart that checks and displays the remaining time that a password needs to be changed. Well solution 1 is near finished and I must say that the part that took most of my time was interfacing with Active Directory to find out when a password was about to expire. It turned out to be the following property : pwdLastSet. The return value of this property was of the following type LargeInteger. I used the solution which I found at .Net Directory Services Programming - C# - Part 1 in the comments section :) See the following code that takes user class

public static void GetAccountExpiration(CUser user) { try { string LogUser = user.UserName; DirectoryEntry entry = new DirectoryEntry("LDAP://domain"); DirectorySearcher search = new DirectorySearcher(entry); search.Filter = "(SAMAccountName=" + LogUser + ")"; SearchResult LDAPresult = search.FindOne(); entry = LDAPresult.GetDirectoryEntry(); // Pulling the informtion on when the password was last changed and converting it to a LargeInteger. LargeInteger liAcctPwdChange = entry.Properties["pwdLastSet"].Value as LargeInteger; // Convert the highorder/loworder parts of the property pulled to a long. long dateAcctPwdChange = (((long)(liAcctPwdChange.HighPart) << 32) + (long)liAcctPwdChange.LowPart); // Convert FileTime to DateTime and get what today's date is. DateTime dtNow = DateTime.Now; // I added 90 days because I know what my password expiration is set to, if not you need to pull that information and add the number of days it is set for. CultureInfo ci = new CultureInfo("nl-NL"); DateTime dtAcctPwdChange = DateTime.FromFileTime(dateAcctPwdChange).AddDays(#number of days that is set in the AD group policy); string strAcctPwdChange = DateTime.FromFileTime(dateAcctPwdChange).ToString("d",ci); string strAcctPwdExpires = DateTime.FromFileTime(dateAcctPwdChange).AddDays(#number of days that is set in the AD group policy).ToString("d",ci); // Calculate the difference between the date the pasword was changed, and what day it is now and display the # of days. TimeSpan time; time = dtAcctPwdChange - dtNow; if (time.Days < 10) { WebMail mail = new WebMail(); mail.To = user.EmailAddress; mail.From = "admin"; mail.Subject = "Password expiration"; mail.Body = "Dear user.UserFirstName,
you've changed your password for the last time on strAcctPwdChange.
Your password is about to expire on strAcctPwdExpires.
Please change your password as soon as possible"; mail.SendMessage(); } } catch { } }
As you can see the, this is all to it. Just write a function to get all the users and put their usernames through this function ;) I got all my users from a database from another application where I administer the users. I almost forgot to mention you have to reference "activeds.tlb" in the system32 directory and then add 'using ActiveDs' in your project. Solution no2 is being worked on and it's not very different from the first solution. I can use most of the function that is described above.