.. I know you will find this useful. I just know it.
Carl Franklin and I recorded DNRTV #3 on SharePoint 2007 last weekend. This show was targeted towards ASP.NET 2.0 Developers, and we dove into two specific aspects
a) Interacting with the API
b) Writing Custom Web Parts
The show, should be online in about a month's time. Meanwhile, you can check out my code-magazine articles and developer.com and codeguru.com articles, and of course my blog about writing custom webparts. I have talked quite a bit about writing webparts, but the other portion - interacting with the API, I haven't talked much about (atleast publicly).
In this DNRTV show #3, I talked about interacting with the API, and the specific example I choose was a couple of utilities I have written with help from Angus Logan (Microsoft Australia), and will be available on codeplex.com. These utilities target user profiles and profile properties, but before I dive into what these utilities are all about, let me explain the background and set a stage for the need for these utilities.
If you are already familiar with User Profiles and Audience Targeting, then dive straight to the bottom of this blogpost where I talk about these tools that promise to make your life easier in production environments.
So lets start. First let us talk about "User Profiles".
User Profiles
MOSS 2007 has a fantastic feature called "User Profiles". Put simply, your MOSS 2007 sites and site collections will be accessible by a set number of users. These users will be split up into groups, and the key differentiation between each user will be their login_id (account name). Out of the box, you can use Windows Authentication, but still there is a primary key of sorts that differentiates one user from another. However, in any organization, a user is more than just a login_id. He has an address, a phone number, email, his manager, HR information, and a number of other things. In other words, a user has a "profile".
This "profile" information is generally stored under a number of systems in an organization - it could be a SAP system, a database, Active Directory, GAL (outlook/exchange), and others. Whatever it may be, SharePoint 2007 provides you with a convenient way to synchronize such user profile information from such stores of information. I have blogged earlier about a step by step process of syncrhonizing such information on both a full import basis and an incremental import basis. Without going into those details in this blogpost, in short, you can import such profile information from Active Directory, Active Directory Resource, LDAP or BDC. BDC further implies that you can import information from anything that has a web service, or can be accessed using ADO.NET. In addition to an import, you can specify mapping. So, "Postal Code" in your SAP HR system may mean "ZipCode" in SharePoint - so on and so forth.
The obvious question here is, what benefit can you garner from having all this profile information synchronized from multiple "islands of information" within your organization? An obvious benefit is, your users now get a "face". Literally, having a full user profile means, you see something like -
... rather than, "MyDomain\Smalik". (Curious about my picture?)
Also, right off the bat, alerts will work because you now have a proper email address associated, you are able to do hierarchical org charts, and a number of other benefits. The really cool thing however is that you can define custom properties, and you can do "Audience Targeting".
Audience Targeting
Audience Targeting refers to the ability, that you as a user can create content, targeted to certain audiences. It is as easy as this, Once you have imported profile information into MOSS 2007, you can say, Create an audience of users that are in California, and Report to Joe Schmoe. This becomes an audience called "Joe Schmoe's croonies in California". Now, Joe Schmoe, or anyone else, can target content to only that group of individuals.
How is this done, you ask? Here is how.
- All this magic lives under Shared Services. So go ahead and under Central Admin, open Shared Services for the web you wish to create audiences on.
- Click on the link that says "Audiences".
- Under "Audiences" create a new audience, specify the rest of the information. I am going to create an Audience called "Smart People".
- Next, SharePoint will ask you to choose rules for that audience. Go ahead and specify some rules. Rules, as you would notice, let you segregate the audiences based on a certain specific user, or group, or based on a property value. You would note that the properties you see in the dropdown, are the same properties you defined in the user profile properties collection. (Read that again - this is where light bulbs should go off). I am going to create a single rule, where personal site contains "winsmarts".
- When you are done specifying the rules, go ahead and click "Compile Audience". In my case, there was one guy (me), who matched the criterion - whose personal site included the word "winsmarts", so the "Smart People" audience is now populated with one single user - me (how convenient). LOL.
My audience is now setup, and you can see this as below -
With my audience setup, the next obvious question is, "How can I use this audience?". In other words, if I had really complex concept that I wished to communicate to only "Smart People", how would I do it? easy.
- Setup a list.
- Go to List Settings, and under "Audience Targeting Settings" check the checkbox that says "Enable Audience Targeting".
- Now, go ahead and add a List Item, you should see "Target Audiences" as one of the information(s) you can specify.
- Type in the necessary information, specify "Smart People" as the target audience. This is show as below on a list of type "Calendar" -
Now when you click "OK", this content will appear to only people who are of target audience "Smart People". In other words, if a user has "winsmarts" as a part of his personal website, he will see this content - others won't.
That, I gotta say, is pretty incredibly powerful.
What about those tools then?
At the beginning of this blogpost, I talked about a couple of tools I have written, with help from Angus Logan (Microsoft Australia), that make your "user profiles" life easier. The two tools are as follows -
a) The first tool allows you to easily transfer profile properties from one web to another web.
b) The second tool, allows you to easily transfer actual profiles based on these proeprties from one web to another web.
These are very very useful if you are moving your site deployment between development and production, or from intranet to extranet, or any other such scenario.
My next couple of blog posts will walk you through these two utilities, how I wrote them, and the code will be available on codeplex.com very very shortly.