Monday, December 15, 2008

Changing fields by code - common oversight

I just helped someone on the OzMOss mailing list who had the following problem - he was trying to change a SPField object, but it was not getting updated, despite of no errors being thrown. Here is a sample of the code he was using:

Guid listID = web.Lists.Add("test", "", SPListTemplateType.PictureLibrary);
SPList list =web.Lists[listID];
SPField myField = list.Fields.GetFieldByInternalName("Title");
myField.Title = "TEST";
The problem with that code is a common oversight that developers who are new to the SharePoint object model usually make - the field object has to be updated. updating the list will have no effect, since the object that was modified was a column on the list, not a property of the list. The right code would be:
Guid listID = web.Lists.Add("test", "", SPListTemplateType.PictureLibrary);
SPList list =web.Lists[listID];
SPField myField = list.Fields.GetFieldByInternalName("Title");
myField.Title = "TEST";

Tuesday, November 25, 2008

How to copy attachments from one list item to another

The microsoft support article for WSS 2 shows us how to download attachments from a list item. Basically, the attachments for a list item are stored as SPFile objects under a hidden folder in the list where those attachments are (a folder called "Attachments") - where each list item that has an attachment has its own folder - with the ID of the item being the folder's name. Here is a code sample for a function to copy attachments from one item to another.

private void CopyAttachments(SPListItem sourceItem, SPListItem targetItem)
     //get the folder with the attachments for the source item
     SPFolder sourceItemAttachmentsFolder =
      //Loop over the attachments, and add them to the target item
     foreach (SPFile file in sourceItemAttachmentsFolder.Files)
        byte[] binFile = file.OpenBinary();
        targetItem.Attachments.AddNow(file.Name, binFile);
  catch { }

Thursday, November 20, 2008

Custom fields with custom properties - important link

If you have developed a custom field type that has custom properties, and now want to create a feature that uses that custom field (to add a site column for example) and want to set the custom property, you may be puzzled how to set the custom property, since the schema of the elements file does not allow it.

I found that Péter Holpár has a solution - I tested, and it works. Basically, just add the custom property with a custom name space - for example, using my datevalidator field type from my teched presentation, you can define it as a site column thus (important bits are highlighted):

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns=""
 <Field ID="{BBC8063E-252E-4fc0-9DC6-CA162512BB33}"
        DisplayName="My Test Validation Field"
        custom:StartDateFieldName="Start Date"
        custom:EndDateFieldName ="Due Date"

I hope it solves your questions as well.

Thursday, November 13, 2008

Using the People picker - how to specify what can users choose

Just got this question in the Ask-The-Experts stand in Tech.ED europe. If I use the people picker like I showed in a previous article, how can I specify if the users can pick a user or a security group or a distribution list?

Well, the answer was in the SDK - there is a property "SelectionSet" that accepts a comma-delimited list of strings that say what can be picked.

For example, "User,DL,SecGroup" will allow users to pick user accounts, distribution lists and security groups. Choosing just "User" will allow only people accounts. The sharepoint people picker ususaly sets "User,SecGroup,SPGroup" or "User,SecGroup" or just "User"

Wednesday, November 12, 2008

My code for the custom fields presentation

As promised, here is the code I used. For the PowerPoint presentation I need to get approval, so wait for it.

The code has three samples of custom field types - one is a prime number validation field type (allows people to type only prime numbers), one is a date validation field that checks two other fields that the end date is after the start date (this is a good example for creating custom properties for the custom field) and the last is a sample how to create a custom look and feel for a custom field, without compiled code - just XML definition (CAML) in the renderpattern section. have fun!

Tuesday, November 11, 2008

Tech.Ed EMEA presentation

I just came out of my presentation in Tech.ED EMEA, and it was great fun! I showed how to develop custom field types, and was very well recceived. My current rating is 8.07 (which is pretty high, especially for a 400 level presentation) and here is some of the great feedback I got:
"I wish all teched sessions were this informative! Maybe some more time for questions."
"a fantastic engaging performance"
"Great session by Ishai Sagi. Keeping it to the topic and quickly answering questions in a good fashion. Great work. Kept me awake although I was rather sleepy (Jetlag? :-))"
"very good presentation, deep look inside sharepoint!!"
I am doing the same presentation again on thursday, and then I will be able to post the content here on the blog. anyone interested?

Tuesday, October 28, 2008

Throwing myself behind the site definitions

Recently on the sharepoint blogs people have begun discussing "site defintions - good or evil" again. I wanted to make my stand, but my fellow MVP Eric Shupps beat me to it and posted exactly what I think of site defitions in his blog.
So thanks Eric for pointing out what I think is right, and doing it so well. The bottom line? Site definitions are not evil, and when time will come to upgrading to sharepoint 14 (or whatever the name\number will be) then site definitions upgrade will be no worse than the features upgrade. Do your site definitions right and that will save a lot of headache, but using all kind of wierd workarounds just to avoid using site defintions is silly, and will not save you time upgrading.
That said, doing the site definitions the wrong way (get into very complex CAML work and use the site defintions as if you are still using sharepoint 2003) can be very detramental to both the current setup that you have, and to the future upgrade path. So make sure you know what you are doing, and follow Eric's advice. I agree with it 100%.

Sunday, October 26, 2008

Cool new free feature - download all files zipped!

This is a cool one - Mohamed Zaki (fellow MVP) just released an open source feature that allows users to download an entire document library as a zip file. Take a look at his blog post about it.

Friday, October 24, 2008

Application pool crash on win2008

This just happened to me - installed sharepoint on win2008, and for the first time ever, when I configured the farm search service, I did not choose "Use all web front end computers for crawling", but instead I selected my server. The result? Sharepoint mangled my hosts file, using IPv6 entries.
This in turn caused my application pools to crash with the error "A listener channel for protocol 'http' in worker process '6120' serving application pool 'SharePoint Central Administration v3' reported a listener channel failure. The data field contains the error number.".
Resolution? I fixed my hosts file, then disabled the IPv6 on my loopback adapter, and restarted the application pool - then I was able to go back to the search service configuration and undo what I did. That again changed my hosts file, so I had to edit it again and done! sharepoint is working again - ready for TechEd EMEA.
Talking about Tech.ED EMEA, I still didnt get any takers on the competition I started. Apparently a lot of people signed up to my presentation - enough for the teched administrators to ask me if I don't mind presenting twice (I don't - see me on tuesday or thursday). If you want to win a special prize from Australia, and are coming to Tech.ED Barcelona, comment here - and I will draw a prize from all the commenters who are there. Please leave full name.

Monday, October 20, 2008

New SharePoint book coming up - by me!

If you have a lot of end users asking you how to do stuff in sharepoint, maybe you should preorder this book. I have been writing it in the last few months, and am getting close to finishing it, and it is already up for pre ordering in Amazon.

This book is intended for non technical users.(Not for developers or administrators) who want a SharePoint companion to help them with day to day sharepoint tasks - things like "What is sharepoint?" and "How do I switch views in a list?" or "How do I create a view?" and so on.

I am very excited about this - and I hope it will be a success so I can write some more books - maybe the next one will be for you - the developer? But that will only be possible if this book is a success, since writing is a lot of effort. So, please, tell your friends, and get your purchasing officer to pre order some - it is on discount!

Tuesday, September 30, 2008

Developing Custom SharePoint fields - coming soon to Tech.Ed EMEA!

Are you from Europe? coming to Tech.ed in Barcelona? Well, make sure to catch my presentation about developing Custom SharePoint fields! Update:The session will be on November 13 09:00 - 10:15 (Why is it that my presentations are always either the first thing in the morning, or the last before the party?).
If you are a long time reader of this blog, and coming to Tech.ed, comment on this post, and leave your (real!) name - I will draw a prize for one person who commented on this post. I havent decided on the prize yet - but it will be coming all the way from Australia - for you to take home if you are there at the end of my presentation, and can prove your identity using the Tech.ed name tag. (note - if there are two or more people with the same name, I will ask questions about custom field development and the best answer wins!)
See you there!

Tuesday, September 16, 2008

Offtopic - Zune new updates do not work on win2008 (Update: solution!)

Update with a solution to this below!

What's this? I was so happy that the zune software runs on my win2008 laptop, and now the new version refuses to install? bah!

Notice something strange - the "supported" only quotes 32bit operating systems, even though I downloaded and (tried to) installed the 64bit version.
It seems that Microsoft has the same problem that the software vendors have with supporting commercial software on servers.

It looks like I am doing a lot of hacking my hack to install the solution generator on 64bit machines, resolve this issue is done in a similar manner.
One caveat though -you have to uninstall the old Zune software before starting. In my case the settings were saved, but I do not gaurantee that will be the case for you.

  1. Download the zune v3 software from Microsoft, either 32bit or 64bit version - depends on what you are running.
  2. Using a decompressor like 7-zip, extract the file (right click the file, and choose extract to...)
  3. Go into the folder. It should have a sub folder called "Packages" and in there a file called "Zune-x64.msi" (I don't know what the 32bit one is called)
  4. Double click on that file. The installer may take a while, and at the end you have zune v3 installed on win 2008! (I didnt try to synch yet though - but it is playing music)

Another update - I tried upgrading the device and it failed. It only worked when I did it from my vista machine. So I guess this workaround isnt all that great - and comments below say that connecting to the market place also doesnt work (I cant comment on that because I do not live in the USA and dont have access to the market place)

Wednesday, September 10, 2008

Samsung rant

I like Samsung. I have a samsung TV - and the only upgrade I am considering is to another samsung TV. I'd love to have a samsung SSD for my laptop. I used to have a samsung phone back in 2000 that was the sturdiest and most useful phone I ever had.
So what is this rant about? in teched last week I had a chance to play with the samsung omnia (no, I refuse to put a link. read on to know why). It was great! a windows mobile device that looks and feels like an iphone, but with the extras that the iphone failed to deliver - like a SD card extensions, and a lot of other things that I am sure you can find in your favorite hardware review site.
So, again - why am I ranting? Because I will never buy that piece of c#@$p. Why not? Because of two things. small but hugely important.
Standard USB port? hah! Samsung may have joined the mini-usb alliance, but that didnt stop them from releasing the omnia with a non standard interface. why??? I have so many spare mini usb cables, but if I buy the omnia and my cable breaks, or gets lost or I forget it at home - what then? I cant borrow one from a friend, because they all have deveices that use proper, standard, mini usb ports. I will be shunned!
Standard ear buds 3.5 port? hah! Samsung may try to compete with the iphone, but not giving me the ability to just take my expensive ear phones and plug them into the phone before I go on a run\cycle, just plain sucks. This shows that they don't want the phone to be a multimedia device, and they want us to continue buying their mp3 players (good luck with that - I am a sandisk fan for those. And those that please me, get a link!)

I hope someone in Samsung is reading this. You made a nice phone - but you missed out on two very important features. Come on - a revision shouldnt be that hard, and then you will have at least one customer here in Australia. (oh, and can you put a few more MHz in there while your at it?)

Strange win2008 accessibility issue

In win2008 (64 bit - I havent tested on 32) the speech recognition doesnt seem to work.
I do [Control panel]-[ease of access]-[Use the computer without a mouse or keyboard]-[use speech recognition] and it just opens "my documents".
I asked a few other people, and they all confirmed this is happening on their machines as well. I wonder if I should report this to Microsoft?

How to use the Microsoft Solution Generator on a 64bit machine?

Got asked this question today on OzMoss and I thought I'd share the answer with you.

The problem - the microsoft visual studio extensions for WSS do not support 64bit and refuse to install. One useful application in that package has nothing to do with the extensions - it is the solution generator that connects to a list or a site and creates a visual studio 2005 project out of them - as list or site definitions.

So - how to use it if it wont install if my dev box is running 64bit?

Note: My solution has been tested on a win2003 64bit machine, but failed on win2008 - which I assume has to do with the permissions on the IIS. If anyone can solve this problem on windows 2008, I will be grateful (leave a comment).

The solution:

  1. download the VseWSS1.1 but do not install. save the file ("VSeWSSv11.exe") in a temp folder in your hard drive:
  2. Next, using your zip application of choice (I use the free and useful 7-zip), extrace the file. Yes, I know it looks like an exe file, but using 7-zip (or winrar if you prefer), you can get into the files that are compressed in the exe.
  3. In the files you extracted, there will be a file called "VSeWSSv11.msi". Extract that file as well!
  4. Now there will be a lot more files. We are looking for "". Guess what...extract this one as well!
  5. Now we are getting somewhere. The extracted files will now contain the actuall application files for the solution generator, including the "SPSOLGEN.EXE" file. However, we are not quite there yet.
  6. The final step is renaming 3 files:
    "SPDTFRES.DLL" to "Microsoft.SharePoint.Tools.FileResources.DLL"
    "SPDTRES.DLL_1033" to "Microsoft.SharePoint.Tools.Resources.DLL"

There you go! now you are ready to double click on "SPSOLGEN.EXE" and roll with it. You may want to copy the files to a reasonable named folder first though...

Oh, as I mentioned, this will not work on windows 2008 64bit, not because of the 64bit (I suspect) but because of permissions issues. If anyone has win2008 32bit, can you check and let me know if it works there? and if anyone knows a workaround - let me know!
Just for the record, the error I get on 2008 is "No SharePoint Site exists at the specified URL." when I start the generation.

One last note - the project file generated is for visual studio 2005. If you are like me, and are using vs2008, then instead of using the project file it generates, create a new project, and import the files that were generated. Preferably, a WSPBuilder project...

Monday, September 08, 2008

Common question - how to change the alert email

I get asked this too often in the forums, so hopefully people will search my blog before asking: Customizing Alert Notifications and Alert Templates in Windows SharePoint Services 3.0
and if you want to go a step further and use code
How To: Customizing alert emails using IAlertNotifyHandler

Saturday, September 06, 2008

BDC Column Demo

The following is the first video in a series that shows what I presented on in TechEd Australia 2008. It is not the actuall presentation, but the demos that I used to practice for the presentation.
This one is about using the BDC column in lists. Stay tuned for more!

Wednesday, August 27, 2008

Problems with BDC Definition Editor

Here is a problem I found while preparing for my TechEd Presentation next week (Wednesday evening). I want to show how to use the "Microsoft ® Business Data Catalog Definition Editor" application that helps create BDC ADF files. It allows to connect to a SQL server or a web service, and generates the ADF file, with entities that you choose, and some methods, and then allows you to modify and test your methods. A nice tool all around, but incomplete if you ask me.
The first problem I had with it was when I tried to connect to the AdventureWorksLT database. The database looks like this:

What was the problem? The Definition Editor application connected to the database without any problems, and showed me the tables and views, but when I tried to drag and drop a table to the design surface, I got the following error: "Could not process Table 'Customer'.Make sure you have SELECT Rights on the Table/VIEW."

After searching the net, I have found that many people have seen it, and some have blogged about it, but there was no solution.
I found that if I drag some of the tables in the database - BuildVersion and ErrorLog tables, then it works.
What is different between those two tables and the rest? Well - those two tables are using the DBO schema, while the rest are using the SalesLT schema.
Yes - the BDC Definition Editor doesnt play with custom schemas. Not documented anywhere - so I might as well document it here. I loaded the AdventureWorksDW database, where it doesnt use a custom schema (and all the MSDN samples use for some reason) and what do you know? it works.

Problem 2: The BDC Definition Editor does not generate finder methods. This is very annoying! I mean, when we select a table to be an entity in the design surface, we have a choice to choose which field is the title field for that table, but the editor doesnt do anything with that selection - leaving it up to us to create the finder method that will allow the users to search for an entity by name instead of by ID. WHY???!

Problem 3: This isnt really a problem with the tool, but a problem with me, so here is a hint in case I forget this again - The wildcard character attribute appears when you click on the LOB system node itself. Not at the instance level.

After TechEd I will upload some of my demos here as videos. Interested?

AMD developer site on SharePoint

Just noticed this today (Thanks Bob Fox for pointing it out) - an amazing site done with SharePoint: AMD Developer site

Thursday, August 21, 2008

Ask me a question, win an HP iPAQ

Are you coming to TechEd Australia? Want to ask me a question about sharepoint? use this form, and you may win an iPAQ (they didn’t tell me which model).
Don't forget to nominate me as the person to answer the question.
Oh, you have to be logged in to the teched web site to be able to fill that.

Open letter to laptop manufacturers

Hello. My name is Ishai, and I am a professional developer, who also presents, teaches, and travels with his laptop.
I have requirements from my laptop that are different from home users or business users. Is there anyone out there willing to pick up the slack and build a laptop that would WORK and give me what I need?

Currently I am using a Dell XPS M1330 - which is a wonderful machine. But the manufacturer (to which I will refer as "Dell") will not support 64bit operating systems.
Thats right - I have a problem with the bluetooth on my laptop, and they won't support.So why build a laptop with a 64bit enabled CPU, sell it with 4GB RAM, and then expect your customers to install vista 32bit on it? or XP?
Bad Dell. Very bad.
Moving on - Why can't I get drivers for windows 2008? Why must I hack the nvidia drivers, the bluetooth drivers and still have a lot of things that don't work - just because no one would support a server OS on a laptop?
Where is the brave executive who will say "we make the best laptops for professionals, and we will prove it by supporting the newest operating systems, and provide drivers for everything"? Don't you want the kind of publicity when all presenters of every technical event (teched and such) show up to present with your laptops?

Here is what I expect for a professional laptop line:

  1. Newest Intel\AMD CPU
  2. Support for 4-8GB RAM (for multiple virtual machines)
  3. Screens in 13', 15' and 17' form factors
  4. The 13' model not to weigh more than 1.5kg, and slim
  5. Replacable batteries (for long flights)
  6. At least 4 USB outputs
  7. HDMI (dvi) and VGA outputs
  8. Wireless network (n) module built in
  9. Bluetooth module built in (A2DP)
  10. Option for Solid State Disk
  11. Option for raid of two disks in the larger models
  12. Decent grapics card (preferably not one that burns like the nvidia 8400)
  13. ESATA (or, in the near future USB3)
  14. SD card reader
  15. Full support for windows 2008 server (that includes a support centre helping with malfunctioning)
  16. No crapware installed (that includes the most rediculous "dell dock" - most useless piece of software ever developed by a hardware vendor)
That's it! how hard can it be?
Aperrantly very hard, since no one is offering anything like it...(and before the MAC addicts post here - show me a mac with esata, and tell me if apple supports you with win2008 problems, and do you like to hack drivers?)

Oh, and while I am at it - Nokia - is it too much to expect that your PC Suite will install on a server OS? I am giving you until the release of windows mobile 7 to explain why I can't synchronize my phone because I am using windows 2008...If I don't hear from you, HTC (or samsung) is going to get another sale.

Tuesday, August 19, 2008

My BDC presentation at Teched Australia

TechEd Australia is coming soon, and I have the only 400 level presentation in the Office System track. I will be presenting with American MVP Todd Bleeker, and we will be doing demo after demo after demo - lots!
If you are coming to TechEd and want to hear us talk, make your interest known on the teched site, so we will get a bigger room...

Creating Solutions with the Business Data Catalog
During this session, learn what the Business Data Catalog (BDC) is, why you would want to use it, and how to create applications that leverage the BDC. This session demonstrates what functionality the out-of-the-box BDC Web Parts provide and shows how they can be leveraged to quickly create applications inside SharePoint without writing a line of code! The session also demonstrates how custom Web Parts and Windows Forms Applications may be used to accesses BDC data when the out-of-the-box BDC Web Parts don't meet the needs of a project. Finally, this session demonstrates how to use the BDC and Excel Services KPIs to create powerful digital dashboards.

Infrastructure update kills view functionality in picture libraries

Oh, bugger!

Take a look at Brian Farnhills' blog's latest entry. He has just found that the infrastructure update released last month kills some functionality in picture libraries.

I wonder if that was intended.!AEC42F315B4528B0!2974.entry Update - I have opened a support request with Microsoft, and waiting for their response. Update - answer from Microsoft PSS - "known issue". They are checking to see if there is anyone working on a hot fix. By the way - Brian is presenting at today's Canberra SharePoint User Group meeting about site definitions. Should be interesting!

Grouping and sorting settings of custom fields

In my previous post, I wrote about how sharepoint checks if a field is groupable. One of the things the code there does is check if a field is sortable.

I had assumed that that meant that if a custom field has in it's schema "Sortable=False", then it would not show up in the "sort" and "group by" dropdowns in the edit and new view pages.

However, it turns out that if the custom field inherits from a field that is sortable (like the text field for example), then what you set in the schema gets ignored - and the field still returns "true" for .Sortable.

I have not found why that is, and the only workaround of how to make a custom field unsortable if it inherits from a text field is to change the code in ViewNew.aspx and ViewEdit.aspx pages to skip those field types.

Not nice.

Thursday, August 14, 2008

How sharepoint determines if a field is "groupable"

Here is one for anyone who ever wondered why a certain field is not showing up in the "Group By" selection box.

You know how you can define in the field definition if the field is "sortable" and "filterable"? Well, what about "groupable"? its not an option! But still, some fields don't show up in the dropdown for grouping in the view settings dialog. How is that set?
The answer is in the aspx file ViewNew.aspx (and ViewEdit.aspx) - these files have server side scripts that has a function "IsGroupable". This function checks if the field should be displayed in the list of fields that you can group by.
Here are the rules:

  1. If the fiels is not "sortable", then it is not groupable
  2. If the field is hidden, then it is not groupable
  3. If the field is set not to display in viewforms, then it is not groupable
  4. If the field is a lookup field and is set to display related items, then it is not groupable
  5. If the field is the built-in file name field, then it is not groupable.
From the list above you can see that it is pretty logical...except #3! Heck! A lot of times you dont want to display the field in views, but you still want to group by it!

So, here you go. If you were puzzled why your field was not showing up - now you know.

Here is the code

protected bool IsGroupable(SPField field)
 if (!field.Sortable ||
  !ShowField(field) ||
  ((field as SPFieldLookup) != null && (field as SPFieldLookup).CountRelated))
  return false;
 if (iBaseType == SPBaseType.DocumentLibrary
  && (field.InternalName == "FileLeafRef"
      || field.InternalName == "LinkFilenameNoMenu"
      || field.InternalName == "LinkFilename"
      || field.InternalName == "NameOrTitle"))
  return false;
 return true;

Monday, August 11, 2008

Goodbye good friend

A good friend, and an excelent sharepointer has passed away last weekend.
Lee Marriage was the sort of person who made everyone like him. He was always ready with a smile, and had an excelent approach to managing people - one that I always envied.
I worked with Lee on several SharePoint projects, and on each one I was in awe at how fast he learned new stuff, how he got the customer to listen to his advice and how he got the people working for him to work in a relaxed, yet efficient manner. I liked his style so much, I recommended and voted for him for employee of the year for last year in our company UniqueWorld
Lee had a sharepoint blog, "The learning curve" which wasn't very active, but the posts he did have were informative. He co-managed the Sydney SharePoint user group, and we were hoping to recommend him to an MVP status soon.

Lee passed away while running the City to Surf fun run from a heart attack. I don't understand how that could be, since Lee was a very fit (not to mention young - 27).I played soccer with him once and was astounded at his skills.
Lee will be missed by his girlfriend, his friends, his collegues in UniqueWorld, the Sydney user group members, and I think the entire sharepoint world has suffered a terrible loss.

Good bye my friend.

Tuesday, August 05, 2008

Why no posts?

If you were wondering why I didn't post lately (almost a month now), there are several reasons. Basically, I am just too busy...
I am writing a book (about SharePoint, but I can't give any details about it yet...stay tuned)
I am preparing for a TechEd Australia presentation on BDC
I am waiting to hear from TechEd Europe if they want me to present one of 11 presentations I sent to them and are on the waiting list, and I also have a private life (believe it or not). so...sorry, but posts are low right now.

Do not read from the SharePoint Database (unless you absolutely know what you are doing)

Other developers always ask me this, and it is a very common question in the forums. Many people argue that there is no danger in read only access. So for future referance, here is the Microsoft article that describes the issue, and an extract from it. (My thanks to Shane Young who sent me the link lately and reminded me where is was).

"customers are strongly advised against direct access in a read-only manner to these databases unless Microsoft protocol documentation is followed exactly. Accessing these databases programmatically or manually could cause unexpected locking within Microsoft SQL Server that can result in overall performance problems."

What accounts does the people picker show

I was asked this the other day - "In a user field, what determines what accounts are displayed to the user?" Well, ofcourse that depends on some factors such as what authentication provider you are using, but if you are using the default (window active directory) provider, then the LDAP query that defines what users are returned is embedded in the field control.

I took a look (reflected) the control and found the query that is being ran.

That was easy enough - the trick is understanding this long query....From my minimal understanding it is looking only for people or groups (depending on the setup of the field) and only those that are enabled in active directory (userAccountControl=2) where the name or display name or email address or account name or SIP address starts with the text the user entered.

Here you are - from the inside of the DLL:

"(&(objectCategory=person)(objectClass=user)(!(userAccountControl:1.2.840.113556.1.4.803:=2))(|(name={0}*)(displayName={0}*)(cn={0}*)(mail={0}*)(sn={0}*)(SamAccountName={1}*)(proxyAddresses=SMTP:{0})(proxyAddresses=sip:{0}){2}))", "(&(objectCategory=person)(objectClass=user)(!(userAccountControl:1.2.840.113556.1.4.803:=2))(|(name={0})(displayName={0})(cn={0})(mail={0})(samAccountName={0})(proxyAddresses=SMTP:{0})(proxyAddresses=sip:{0})))", "(&(objectCategory=person)(objectClass=user)(!(userAccountControl:1.2.840.113556.1.4.803:=2))(|(mail={0})(proxyAddresses=SMTP:{0})))"), new SearchParameter("(&(objectCategory=group)(|(name={0}*)(displayname={0}*)(cn={0}*)(SamAccountName={1}*)(mail={0}*)(proxyAddresses=SMTP:{0}){2}))", "(&(objectCategory=group)(|(name={0})(displayname={0})(SamAccountName={0})(mail={0})(proxyAddresses=SMTP:{0})))", "(&(objectCategory=group)(|(mail={0})(cn={0})(proxyAddresses=SMTP:{0})))"), new SearchParameter("(&(objectCategory=group)(groupType:1.2.840.113556.1.4.803:=2147483648)(|(name={0}*)(displayname={0}*)(cn={0}*)(SamAccountName={1}*){2}))", "(&(objectCategory=group)(groupType:1.2.840.113556.1.4.803:=2147483648)(|(name={0})(displayName={0})(cn={0})(samAccountName={0})))",

Sunday, July 13, 2008

Updating web part properties, without the tool pane

here is a nice developer article for you - something I see asked a lot of times, and Rob Nowik is answering with a great how to article: Updating web part properties, without the tool pane

Wednesday, July 02, 2008

CAML sorting by file name

If you are doing a CAML query and want the results sorted by the file name (and not by title, which may be different than the file name) use the following:
<OrderBy><FieldRef Name='LinkFilenameNoMenu' /></OrderBy>

Monday, June 30, 2008

Access denied when trying to open a site when on the server

I just wasted half a day trying to figure out why some feature code was not working.
The feature code used HTTPRequest to get a file from the layouts folder- and kept failing with “Access Denied”.
It also turned out that when I logged on to the server I couldnt browse to the site - it asked me for credentials all the time.
After wasting a long time debugging and troubleshooting, this support article saved the day - a little registry change and everything works.

Wednesday, June 11, 2008

Showing "my links" on a web page

You know how users can have a list of links known as "my links" in MOSS? (not WSS) It has a nice web interface for managing favorites and storing them in the user's "my site", and even group them by groups, and display them in every page on the top as a drop down menu:

Well, what if you want to show the list on a page? easy - they exist as web parts, but ones that do not exist in your web part gallery by default.

  1. Open Site actions>Site Settings

  2. Click on "Web Parts"

  3. Click on "New"

  4. Scroll down in the list to find "QuickLinksMicroView" and select it

  5. Click on "populate gallery" and go to the page where you want the web part.

  6. Add the web part to the page

The web part has only two properties to customize it:

And at the end it looks like this:

Monday, June 02, 2008

Things to think about when planning a SharePoint solution

Here is a list of things that people seem to forget when planning a sharepoint solution:

  1. There will be many users using the solution at the same time. Make sure your solution is able to deal with that.
  2. When developing a web part or a custom field control, always remember that more than one instance of it may be on the same page. Lack of testing of what happens if you put two web parts side by side on the same page may cause scripts to clash if you didn't plan right.
  3. Most (all) sharepoint implementations have more than one front end server. Plan for your solution to be able to spread across multiple servers, and make sure that when it does, it load-balances!.
  4. Dont forget logging of errors in this case should make it easy for the admin (or yourself) to find where the error was- regardless of the server that was serving the client when the error occured.
  5. Performance! users do not like to wait more than 3 seconds for a page to load - and if your web parts are not performing well, you will ruin the browsing experience in the site. Use caching techniques to improve page loads.
  6. Remember when caching that some things should be cached on a user level, and some can be on the application level.
  7. In web controls - remember error trapping. This may be obvious to anyone who ever developed anything, but this happens so often that I have to just say - I don't care what you do with your errors - but don't crash my page! Make sure everything is nicely wrapped up in try-catch, and never throw an error to a page. Remember that other people (controls) are using it as well - it is not yours.
  8. Develop for deployment. Make sure you plan a WSP package, and document well the list of all the things that will be required that cannot be deployed using a WSP package (changes to the web.config aside from safecontrols for example)
  9. CAS!

Sunday, May 18, 2008

A must read blog post -everything about AllowUnsafeUpdates

If you are a sharepoint developer, you have to read this one: What you need to know about AllowUnsafeUpdates. While you are there, take the time to register to that blog. Hristo Pavlov looks like a blogger to watch for!

Friday, May 09, 2008

Tweet - writing code that accesses a site in another application pool

sorry for the tweet - no time to explain.
<TWEET> If you are writing code that accesses (or potentialy accesses) a site in another application pool, make sure that the application pool account for the current application pool has database permissions on the database for the other application. otherwise - you'r objects will not get created. </TWEET>

Thursday, May 08, 2008

Access denied when trying to get to shared services

In the last couple of days a person next to me was trying to install SharePoint and failing every time with the shared services. After setting up the shared services, he couldnt open the shared services site - it would "access denied" him, no matter what account he tried to log on as (and we even tried the application pool account).
We immediatly suspected that kerberos wasnt configured correctly, that we didn't give enough local permissions for a system account or that some metaphysical entity just hates us sooo much.

Today I sat with the guy and watched him configure everything correctly. Still - access denied. damn!.
I turned to my trusty friend google, typed "sharepoint ssp access denied" in the search box and the second result had not only a workaround - but also an explanation why it happened and how to avoid it in the future.
So first of all - thank you Faraz for finding a work around, but more importantly - thanks to Scott who wrote the following in the comments:
"DO NOT call you SSP the same name as the AppPool you use for the SSP Admin Site.
The SSP actually uses its name to create an AppPool for use under the Office Search site.
If your SSP Admin AppPool is the same name then MOSS sets it to use the timer svc account.
If your hosting then call the SSP Admin AppPool 'Company - SSPAdmin' and the actual SSP 'Company - SSP'. This will stop MOSS clobbering the accounts.

This was exactly what we did wrong! We created a new SSP and this time made sure the SSP name is different from the application pool name, and here we go! ready to start.
So, if you are the Scott who wrote that comment - I thank you.

Monday, May 05, 2008

A Lookup to the sub sites

A question from the forums:
"I'm creating a WSS 3 site which will have a new subsite each time there is a planning application.
From the parent site I want to be able to enter documents and say which application it belongs to but I don't want the user to have to maintain a list of application names when they could just lookup to a list of all the Application subsites that have been created.
Does anyone know if that's possible?

My Answer:
This is not possible out of the box (unless you use the SiteDirectory template, and create the application sites' there).

To code it, here are several options:

  1. either connect a workflow or an event handler to a list of applications, and the workflow\event handler can create the site for you.
  2. Develop a custom field control that will load the list of sub sites for the user.
    This should be more robust than option 1, since a workflow\event handler may fail to create the site and you will end up with a mess. however, custom field controls are not supported by office - so you will not be able to set the metadata on documents from within the office applications.
  3. Develop a timer job that synchronizes the list of sites into a choice field as choices.
    This will be robust, and will work in office - but will put a load on the server
  4. RECOMMENDED: develop a feature for the application sites that will add the name of the site to a list when the feature is activated.
    This will be better than option 1 because you can trigger it again if it fails, without re-creating the site. Also it will have much less load on the server than option 3, and better performance than option 2 since it will not have to check the sites every time someone wants to upload a document. Also - easy development.
  5. Develop a BDC application (using a custom web service) to show the list of applications based on the existing sites.
    This may be the second easiest option (after #4) - such a web service is easy to develop. But this will only work if you have MOSS license, as the BDC is not part of WSS.

Thursday, May 01, 2008

My TechEd 2008 Presentations are on video

I gave a presentation in TechEd Israel a month ago, and it is now available to view on streaming video from Microsoft Israel.
The presentation is building an end-to-end community solution using the Microsoft Office System (sharepoint+word in this case) - using web services, custom task panes in office and even a bit of WPF thrown in for good measure.
The powerpoint is in english - but is mostly empty since 90% of the presentation was done in visual studio. If you want to see it, download it here.
The video is available for either streaming or download, but be warned - I am talking in Hebrew (and very quickly...sorry about that - wasn't given enough time to do it properly). If you are interested in seeing how to code a sharepoint web service that reads word 2007 documents and exposes their contents to a custom task pane in word, then by all means, download and watch - just mute the sound (I don't like how I sound in recordings anyway).

The other presentation I was involved in was "the 7 great tips of sharepoint deployment" where I gave the winning tip (using WSP to deploy solutions to farms). The other tips are also interesting, and again the powerpoint is in english while the video is in Hebrew - stream or download.

Monday, April 28, 2008

Antarctic pictures

I promised some people I would publish some pictures my girlfriend brought back from Antarctica, so here you are.

Tuesday, April 22, 2008

Event handlers configuration settings best practices

Where to place configuration settings for event handlers?
I have thought about it and came up with a few options:

Place config information in the event handler registration info
Every time you register an event handler with a list you can specify data specifically for that registration. This can be done with a feature, or using code (see my utility pack for an easy way to do that)

  1. Can be deployed using a feature. We can have different config per list.
  1. We only have a seperate config per list (no one place to manage all lists).
  2. Limited to 256 characters.
  3. You will need to run code to change the configuration.

Place config information in the web.config <appSettings> section
I was surprised to find that the event handlers get access to the web.config as if they were web applications. Cool!

  1. One place to manage per web application. can be deployed using a web application feature and some custom code (
  1. Hard to deploy every time you create a new web application in the farm. This can be resolved by creating a feature and stapling it at the farm level (scope is webapplication) that modifies the web.config to include the section you want, and setting some defaults - so that the event handler finds what it is looking for when a new web application is created.

Place config information in a settings file on the file system

  1. One place for the enitre farm, can be deployed using a solution package
  1. Location is hard coded in the event handler (unless we use this approach mixed with option one!).
  2. Folder must allow users to read, or impersonation will be required.

Place config information in a settings file in the GAC, next to the assembly
I used this a few times. You can put a file right next to the dll, and use a helper class in the dll to deserialize it and read the values.

  1. one place for the enitre farm, no hard coding of location.
  2. Use Mide Woodring's AssemblySettings class to read from it. can probably be deployed as a farm feature
  1. Every time a new dll version is entered, the config will be deleted and will have to be added again.

Place config information in a document library\list in the root sharepoint site of a site collection or in the central administration site or the shared services site for that web application

  1. Deployable as a feature at the site collection level
  1. still requires custom code to get the config.
  2. performance hit on reading the configuration (can be minimized with caching).
  3. (if root site collection option) Only supports site collection level configuration.

Special thanks to Reza Alirezaei who pointed out some spelling mistakes and commented on the web.config section.

Monday, April 21, 2008

Checking the current user's permission on a web site or a list by code

in answer to a question in the forums:

SPWeb has a "CurrentUser" attribute which gives you a SPUser object. the GetAssignmentByPrincipal function of the RoleAssignments collection of the SPWeb object will get you what roles the current user has.


here is an example:

SPWeb web = SPControl.GetContextWeb(this.Context);

SPRoleAssignment assignment = web.RoleAssignments.GetAssignmentByPrincipal((SPPrincipal) web.CurrentUser);

StringBuilder sb = new StringBuilder("");

foreach (SPRoleDefinition role in assignment.RoleDefinitionBindings)








This sample will give you a string with all the information. if you want to check if a use is allowed to add list items


note - don't dispose of the SPWeb object in the example above, since it comes from the context.


another note - this checks the web site permissions - not the permissions for a specific list. if you want to check a list you will have to get the roles from an SPList object. in the following example I am doing the same for the announements list in the current site:


SPList list = SPControl.GetContextWeb(this.Context).Lists["Announcements"];

SPRoleAssignment assignment = list.RoleAssignments.GetAssignmentByPrincipal((SPPrincipal) web.CurrentUser);

StringBuilder sb = new StringBuilder("");

foreach (SPRoleDefinition role in assignment.RoleDefinitionBindings)







How to find the default SSP with code

Answer: (update - thanks to Gary Lapointe who pointed out that my last post used internal objects, I actually tested my code and did more research and found that there is no way in the API to get to the default. If someone knows of a way I'm happy to learn. for now, here is a workaround that I have found - using the STSADM command line)

Process stsadmProcess;
stsadmProcess = new Process();
stsadmProcess.StartInfo.WorkingDirectory = @"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN";
stsadmProcess.StartInfo.FileName = "stsadm.exe";
stsadmProcess.StartInfo.Arguments = "-o enumssp -default";
stsadmProcess.StartInfo.UseShellExecute = false;
stsadmProcess.StartInfo.RedirectStandardOutput = true;
stsadmOutput = new StringBuilder("");
XmlDocument xdoc = new XmlDocument();

Thursday, April 17, 2008

Open microphone event in Sydney next month

Just got this from Lee in Sydney:

Sydney SharePoint User Group is pleased to bring back Mike Fitzmaurice to Australia– Monday May 5th 2008

Would you like to find out;

  • How can you leverage Microsoft Office SharePoint technologies to provide a platform for collaboration, ECM, search, BI and social computing?
  • The interoperability with MOSS and other line of business applications such as SAP?
  • How SharePoint and Office can be the people friendly face of service oriented architecture?

Well we’ve got just the man to answer those burning questions... Microsoft’s Mike Fitzmaurice, Enterprise Technology Strategist and former Technical Product manager for WSS/MOSS, has kindly agreed to hold a lunch time ‘Open Mike’ session when he visits Sydney in May.

We look forward to seeing you there!

Please click here to register for this event.

Registration opens at 12:30pm and the Q&A session commence at 1:00pm. The May User Group will be held at the Microsoft’s office, 1 Epping Road, North Ryde, Sydney.

Food & Refreshments will be provided.

‘Open Mike’ – Mike Fitzmaurice Q&A Date: Monday May 5th 2008 Time: 12:30-2:00pm

Visit for further information.
Mike Fitzmaurice Mike Fitzmaurice is an Enterprise Technology Strategist at Microsoft, advising customers, partners, and Microsoft teams on portal, collaboration, and search technology. He spent the past five years as a Technical Product Manager for Windows® SharePoint® Services and Microsoft® Office SharePoint® Server, focused on developer evangelism and interoperability issues. He joined Microsoft Corp. in December 1997 as a senior consultant for Microsoft Consulting Services, overseeing several development initiatives involving Exchange Server and SharePoint technology for a wide range of customers. Before joining Microsoft, Fitzmaurice served as Director of Research and Development at Advanced Paradigms Inc., a Washington, D.C.-based Microsoft Solution Provider Partner, as well as a five-year tenure as IT Director of the National Association of Broadcasters.

MVP summit - The SharePoint MVPs rock!

There is simply no competition. If anyone asks you what kind of MVP you want to be - say SharePoint. We are the best group of MVPs in the summit.
What makes me say that? read this from Lawrence Liu (Microsoft) about what we did this week.

Tuesday, April 15, 2008

Off topic- do you like pictures? see my other blog

In case you don't know, I have a private blog in hebrew, where I post pictures that I take of my life in Australia (and around the world).

Even though the description of what is going on is in hebrew, the pictures are in english (joke) so if you want to see - check it out at

Or, if you dont want to see the hebrew, just look in my picasa albums: and

Here are some samples of my attempts at photography:

Day 1 of the MVP summit - gaming discussion, kangaroos and

After the previous post I went to a session where we discussed the gamer community and how to promote it. we talked long and hard about many problems in the gaming community and it was very interesting. Would you agree that gamers have better hand-eye coordination than non gamers? would you agree that gamers are less likely to use drugs?
Anyway, after that we had welcome dinner and I hung around with the other Australian MVPs. Our Australian lead from Microsoft (Rose) brought two inflatable kangaroos and our table was the most popular table - so many people came to take a picture with the kangaroo. Since I was standing behind it, I am sure you will be able to spot me in blogs all over the world.
Hey - lets make a challange out of this - spot me in a picture from a different blog, post it in the comments, and I will...errr...I have no prizes, but I will post a big thank you right here for you!
Here is a blog with the kangaroo picture (but no Ishai) so you can see what it looks like.

Another MVP from Australia was promoting Schnubbs - the .NET tiger. Check out Schunbbs' blog and enjoy. He posted some pictures from yesterday soon - including one of mine with Schnubbs on my head:

Monday, April 14, 2008

First day in the MVP Summit, Seattle

So, I arrived here yesterday for the great MVP Summit of 2008, but I am sick. I am sneezing and coughing and my head is swimming. I guess people here will remember me as "that guy who kept coughing during the presentations".

For that reason I am missing the annual SharePoint MVP paintball game that is going on now, and I am sitting in my hotel room, writing this post.
On a brighter note, I have visited the Seattle Aquarium this morning and found it a very nice one - very well displayed. You have to love those otters.

Today we have nothing serious to do - some open sessions that I was planning to go to, but that have nothing to do with SharePoint - so I am resting and trying to build up my strength for tomorrow. That is when things get interesting and I will be hearing all kind of plans for SharePoint, and meeting with the people who make the product. Do you have any questions you want me to ask? just comment on this blog post, and I will try to get you answers.

Sunday, April 13, 2008

Tech.ED Israel 2008 done - now in Seattle.

Hope you got to see me last week in TechEd Israel. It was a lot of fun to meet so many friends, and past customers. I didn't get enough time to do the presentation I had properly, but I got it done in exactly the 60 minutes that were alloted to me. I hope people can forgive me for the speed - but I was playing with what I had. I wonder how my feedback was...I will let you know if they tell me (and if it was good).
I have also taken part in an exciting presentation by 7 presentors- it was a competition between us to deliver the best MOSS deployment tip in 7 minutes. If we went over 7 minutes, a "police man" would drag us off the stage (it happened to two presentors). Then, at the end, the crowd was asked to clap for the best presentation, and the "police man" judged the claps and announced me the winner with my tip of "deploy using WSP solution packages". I won a LifeCam vx-3000, which I will contribute to the Canberra SharePoint User Group as a door prize in next month's meeting (May).

I am now in Seattle, a bit sick and jet lagged, but hopefully well enough to learn more about SharePoint and it's future in the next week. If you are an MVP and here, look me up - I am the one with the crazy hair-do!

Tuesday, April 01, 2008

April's Fools! I am still an MVP

Hope you didn't buy into the post from yesterday where I sounded a bit down for not getting the MVP award. While everything written there was 100% true, the tone was the joke - I wasn't really worried, and only wanted to see who will bite! hehehehe...
Anyway, during the night I got this email:
Congratulations! We are pleased to present you with the 2008 Microsoft® MVP Award! The MVP Award is our way to say thank you for promoting the spirit of community and improving people’s lives and the industry’s success every day.
So I am an MVP for one more year. I hope to earn it again next year - so I'd better keep posting here, answering in the MSDN forums and improve the Canberra SharePoint User Group!

Monday, March 31, 2008

Not an MVP anymore, but going to the summit and to TechEd Israel

Well, unless I get an email in the next couple of days, I am no longer an MVP. Exactly one year ago Microsoft granted me the MVP award for my contribution to the sharepoint community. I am hoping that this will be the same this year as well - but so far I hadn't heard from them. Then again - it is too early in the United states, and it could be that they are taking my advice from last year that sending the "you are an MVP" email on April's fools day is not a good idea...

I think I contributed quite a bit this year. True, I didn't blog as much, and I didn't start any new open source projects - but I am still leading the Canberra SharePoint User Group (and spent some time on developing the site and the user base. The last meeting we had 32 people come in - and that is in Canberra!). I have also answered quite a bit of questions on the SharePoint developers' forums in MSDN. Look at today's log of top answerers from the last 30 days:

If the award gets renewed, I'd be sure to let you know. but for now, I will remove the MVP logo from this site and from my email signature. If not, then I will try harder next year!

So next week I will be in Israel for the Israeli TechEd. I will be presenting a most difficult presentation on how to create a community site solution, integrating office 2007 open XML and sharepoint, with web services, VSTO and even windows presentation foundation thrown in for good measure.

The week after that I will be in Seattle for the MVP Summit where I will meet the SharePoint team, listen to lectures and mingle with other MVPs. If you are an MVP - look me up - I am the guy with the horribly big hair style and the stubbly facial hair:

Product Review of the week - Tzunami Deployer

As promised - another product review. This week - Tzunami Deployer.

This application is used to copy data into SharePoint. The source of the data doesn't have to be sharepoint, but it has modules that support all versions of SharePoint as sources - so if you want to migrate data from your old sharepoint 2001 or 2003, this is the tool you are looking for. Other modules they have for sale are "file system" (I can hear some ears perking up...), "lotus notes" (a lot more ears?) "exchange", "livelink" and "eRoom"...interesting?

The Tzunami product allows you to model the data migration path manually - by loading the source and the target in two panes, and then dragging and dropping items (either documents, list items, document libraries and lists or event whole sites with sub sites) and then allows you to manually map metadata fields.

The application main screen. Source is on top.

Mapping metadata fields from source to target.

There are important options like adding missing metadata fields to the target if they don't exist (or skip them) as well as security mapping (very important when moving between domains for example).

However, the big advantage of this tool compared to others I have tried is the "rule wizard". This feature allows you to predefine some rules on what will happen when you drag and drop. For example, you can specify that certain lists type will not be migrated, or that document libraries with specific names (or other properties) will be migrated using a specific predefined metadata mapping - and more and more. This richness of the rules wizard clearly makes Tzunami Deployer a very good tool - as it saves a lot of manual time.

Finally, after you have modeled your deployment, you can "commit" the changes - at which point the application actually creates the sites\lists\libraries and copies the list items\documents. The application supports migrating versions as well as security settings, and retains the built-in fields like created, modified, created by and modified by.

Did I mention that the modeling application does not need to run on a sharepoint server? You just need to install the "remote deployer" on the servers you are deploying to\from, and you can run the application from any desktop. However, since it is the application that commits - it is recommended to run the commit on the receiving server - to reduce network load if nothing else.

That said, the developers in Tzunami still need to work on a few things. The user interface is at times frustrating - dialog boxes that cannot be resized (and you are stuck with annoyingly small treeviews with scroll bars) and dialogs that pop up without an option to set a default answer - something like "remember my answer, and apply to all" - specifically on metadata mapping. The metadata mapping dialog box will popup for each list and document library that you have dragged and dropped. This makes dragging and dropping a hierarchy of sites with a lot of lists and libraries a very annoying process - and can cause the application to crash if we are talking about thousands of lists (have you have tried to click "next" three thousand times?). The boys there assure me they are working on it.

But the biggest problem that I see with the software is that it is impossible to model a migration path and then run it on different servers. Basically the application stores the setting of the source and the target in its "project", and will not let you say "do that again, but this time on that server". This makes going through a series of tests (as in, development-test-production) impossible - since you will still have to do the dragging and dropping all over again. But if you are careful - and you make sure you dragged and dropped correctly, and you make maximum usage of the rule wizard (which is defined by XML files - which you can even generate yourself by code, a thing I find very useful), you can work around this limitation.

Bottom Line

The flexibility of the rule wizard, coupled with the awesome support level I have been getting from the Tzunami support team (which is fantastic considering that I am in Australia and it is very hard to support us since we are usualy at a huge time difference with anyone else in the world) would have given this product a much higher score, if the annoying UI and some stability issues were gone. However, if you know what to beware of, and have enough patience for trial and error on the rules and how they work - you will find Tzunami to be your best friend. I give Tzunami 3.5 SharePoint Tips stars.