Syrinx on SharePoint

Syrinx SharePoint Team Blog
Need help on your project? info@syrinx.com, or toll free (888) 579-7469, press 1

News



Need help with your SharePoint project?

Syrinx works with clients throughout New England and across the United States to architect, design, develop, and deploy SharePoint implementations. Working on fully outsourced projects, as part of your team, helping to train your team, or rescuing projects in trouble, we are comfortable doing it all. Projects from a couple weeks to several months in duration, reference clients available. Contact us today - info@syrinx.com, or toll free (888) 579-7469 and press 1 to speak to someone now!

SharePoint 2007 Employee Directory Web Part

Many of our clients have asked us about some type of function or Web Part that lets them show a list of users in their site collection, specifically from the "Users and Groups" list that they can control.  Out of the box MOSS gives you the Site Users Web Part.  This is often discarded by the client because it is too basic.  Here is what it looks like:

  clip_image001

We are generally asked if we can show profile pictures, some imported Active Directory profile information, sorting, links to the user display or My Site page.  In order to do this we chose to write a custom Web Part.

The point of this article is to show SharePoint developers an alternative method to using the Site Users Web Part as an employee directory.  We will show the basic steps to create your own Web Part to offer more information and flexibility while introducing you to some SharePoint functionality you may not be familiar with.

This article assumes you are familiar with Web Part development in SharePoint 2007 and already understand how to build and deploy a basic Web Part with a basic understanding of ASP.NET development.

 

The Code and the Process

Recently for a client we needed to pull user information from the root Site Collection to create a "Face Book".  Since users and permissions are Site Collection-based, this allows the local administrator to manage the list of users that will be visible in the Face Book.

We chose to use the SPList SiteUserInfoList to obtain this data.  We will go into the details of this list in another post, but for the purposes of this article it is the Site Collection-based user/permissions list.  We used the list located at the Site Collection's root Web:

clip_image001[6]

The SPList object does not support binding to a DataTable, but a hidden gem in WSS 3.0 is the ability to call SPList.Items.GetDataTable().  This returns an SPList object converted to a DataTable object which can more readily be used with grid controls.

We also chose to use the SPGridView instead of the standard GridView from .NET 2.0.  The version specific to SharePoint creates default formatting to match standard WSS 3.0 Web Parts.  One item on my wish list from this experience would be that an SPList could be bound to an SPGridView natively without requiring the conversion to a DataTable object.

In the OnInit() event handler we add to our control tree and this is where we set up all our UI Controls.  Below is a snippet of code that shows wiring up a DropDownList to handle filtering by Active Directory department, creating the SPGridView and adding a few different types of columns to the display grid.

clip_image001[11]

In the OnLoad() event of the page we simply call the Method to Load the Data.  We call this with the SPSecurity.RunWithElevatedPrivileges so that any data accessed with be run with administration privileges.

The Bind method looks like this:

clip_image001[5]

We iterate through the User DataTable in order to make some changes along the way.  SharePoint likes to store some data with delimited values in a single field.  It does so with the user's profile picture URL.  We have to split this value in order to assign it to an ImageField column.

Next it shows the limitation of the UserInformationList.  Without going into detail in this article, this data represents a small subset of the Profile Data you might expect to be available at the Site Collection level.  In order to get Profile data not available in the local context, we must load a UserProfile object to obtain the Mobile Phone data we needed to display.  Not the most elegant solution, but it worked.

At this point we assigned the DataView to the DataTable and give a standard RowFilter that removes records from the view that do not contain a last name.  This filters out generic accounts as opposed to legitimate Site Collection users.

Here is the rest:

clip_image001[7]

Next we're checking for a post back and essentially lining up the filtering and sorting so that it maintains state between posts.  The only interesting thing to note here was the need to select a distinct value from the UserInformatonList DataTable.  The only easy way I found to do it was by calling the DataTable.DefaultView.ToTable() method that allows you select distinct records as a boolean and on what columns.  I only needed department because this represented my DropDownList filter.

The remaining code represents the event handler methods to control sorting and filtering.  This is the same in SharePoint as it is in ASP.NET, so I don't think I need to post it.  Below is roughly how the Web Part looks rendered:

clip_image001[9]

I don't have a lot of users in this Site Collection, but you get the point about what an SPGridView looks like, the user data, picture, DropDownList, and sorting.  This should at least serve as a glimpse into what is possible.

-Ryan

Comments

Employee Directory using User Information List in SharePoint 2007 « SharePoint Sherpa said:

Pingback from  Employee Directory using User Information List in SharePoint 2007 « SharePoint Sherpa

# January 30, 2008 2:59 PM

SharePoint 2007 How To List « SharePoint Sherpa said:

Pingback from  SharePoint 2007 How To List « SharePoint Sherpa

# February 12, 2008 8:27 PM

SharePoint, SharePoint and stuff said:

How to get Web 2.0/Enterprise 2.0 and Social Networking into the SharePoint-Platform? This is one of

# May 22, 2008 4:46 PM

SharePoint, SharePoint and stuff said:

How to get Web 2.0/Enterprise 2.0 and Social Networking into the SharePoint-Platform? This is one of

# May 22, 2008 4:50 PM

Mirrored Blogs said:

How to get Web 2.0/Enterprise 2.0 and Social Networking into the SharePoint-Platform? This is one of

# May 22, 2008 5:08 PM

???????????????????? ?????? SharePoint « Admin’s notes said:

Pingback from  ???????????????????? ?????? SharePoint « Admin’s notes

# June 7, 2008 7:10 AM

SharePoint, SharePoint and stuff said:

Web2.0/Enteprise2.0/Social Software A. Free Tools, AddOns and Solutions 1. Community Kit: Enhanced Blog

# June 9, 2008 7:57 AM

Michael Greth MVP SharePoint Blog said:

How to get Web 2.0/Enterprise 2.0 and Social Networking into the SharePoint-Platform? This is one of

# September 4, 2008 2:44 PM

Michael Greth [SharePoint MVP] said:

Web2.0/Enteprise2.0/Social Software A. Free Tools, AddOns and Solutions 1. Community Kit: Enhanced Blog

# June 18, 2009 6:47 AM

R30 Auto Youtube, Br30 Chevrolet El Camino said:

Pingback from  R30 Auto Youtube, Br30 Chevrolet El Camino

# May 21, 2010 4:02 AM

Consommation B2500 Mazda B2000, Youtube B2500 said:

Pingback from  Consommation B2500 Mazda B2000, Youtube B2500

# May 21, 2010 1:58 PM

Exposicion Fotografica Paseo Reforma, Paseo Fremont Avenue said:

Pingback from  Exposicion Fotografica Paseo Reforma, Paseo Fremont Avenue

# May 21, 2010 9:27 PM

Cl600 Full Replacement 1999 Mercedes Benz, Part Shock Absorber Blower Motor Mercedes Benz Cl600 said:

Pingback from  Cl600 Full Replacement 1999 Mercedes Benz, Part Shock Absorber Blower Motor Mercedes Benz Cl600

# May 22, 2010 6:42 AM

Auto Parts Subaru Svx, Part Brat Accessories Subaru Svx said:

Pingback from  Auto Parts Subaru Svx, Part Brat Accessories Subaru Svx

# May 22, 2010 2:51 PM

Intrepid Bulbapedia Password, Headlight Dodge Intrepid 1999 Oxygen Sensor said:

Pingback from  Intrepid Bulbapedia Password, Headlight Dodge Intrepid 1999 Oxygen Sensor

# May 22, 2010 10:07 PM

Substitute Grand Mariner, Submariner Msrp - 413.mfbattle.com said:

Pingback from  Substitute Grand Mariner, Submariner Msrp - 413.mfbattle.com

# May 23, 2010 8:13 AM

Ford Windstar Models, Aerostar Speed Manual Ford Windstar - 448.tijuanareader.com said:

Pingback from  Ford Windstar Models, Aerostar Speed Manual Ford Windstar - 448.tijuanareader.com

# May 24, 2010 9:06 AM

144 Refurbished Support, 144 Shanghai Tube Radio Buizenradio - 480.akemet.com said:

Pingback from  144 Refurbished Support, 144 Shanghai Tube Radio Buizenradio - 480.akemet.com

# May 24, 2010 10:05 AM

C26 C2500 Pickup Rent, C25 C2500 Pickup Hps Filter - 234.tvshowzone.com said:

Pingback from  C26 C2500 Pickup Rent, C25 C2500 Pickup Hps Filter - 234.tvshowzone.com

# May 24, 2010 12:04 PM

Dodge D300 Pickup Grand Caravan Ram 2500, Headlight Bulb Chevy K1500 Pickup - 256.mfbattle.com said:

Pingback from  Dodge D300 Pickup Grand Caravan Ram 2500, Headlight Bulb Chevy K1500 Pickup - 256.mfbattle.com

# May 24, 2010 1:09 PM

Odor 525xi Place, 525xi Bumper Coupon Code - 469.1fh.org said:

Pingback from  Odor 525xi Place, 525xi Bumper Coupon Code - 469.1fh.org

# May 24, 2010 2:09 PM

Terraza Wrench, Adoption 2007 Buick Terraza - 443.cmanager.org said:

Pingback from  Terraza Wrench, Adoption 2007 Buick Terraza - 443.cmanager.org

# May 24, 2010 7:56 PM

Kdf 46e3000 Picture In Picture, Se300 Discount Time Elapsed Percentage Of Fat Burned - 85.an74.com said:

Pingback from  Kdf 46e3000 Picture In Picture, Se300 Discount Time Elapsed Percentage Of Fat Burned - 85.an74.com

# May 25, 2010 3:41 AM

Newport Heater Hydro Quip, Discount Shop Trailblazer Keen Newport Speical - 176.tijuanareader.com said:

Pingback from  Newport Heater Hydro Quip, Discount Shop Trailblazer Keen Newport Speical - 176.tijuanareader.com

# May 25, 2010 3:37 PM

2000 - 1991 @ Bulb Chrysler Conquest Fog Light, Fit Dodge Conquest Headlight Conversion - 204.binggreen.com said:

Pingback from  2000 - 1991 @ Bulb Chrysler Conquest Fog Light, Fit Dodge Conquest Headlight Conversion - 204.binggreen.com

# May 27, 2010 10:20 AM

1999 - 1998 @ Rd250 Sale Two Stroke, D250 Part Frazer Nash Mercury Merkur - 346.an74.com said:

Pingback from  1999 - 1998 @ Rd250 Sale Two Stroke, D250 Part Frazer Nash Mercury Merkur - 346.an74.com

# May 30, 2010 8:14 PM

1997 - 1990 @ Silhouette Van Dale, Aftermarket Oldsmobile Silhouette Cutlass Calais Delta 88 - 390.animejin.com said:

Pingback from  1997 - 1990 @ Silhouette Van Dale, Aftermarket Oldsmobile Silhouette Cutlass Calais Delta 88 - 390.animejin.com

# May 30, 2010 9:59 PM

1984 - 2009 @ W350i Adoption Download, 350 F Open Celsius - 50.binggreen.com said:

Pingback from  1984 - 2009 @ W350i Adoption Download, 350 F Open Celsius - 50.binggreen.com

# May 31, 2010 2:07 AM

1987 - 1991 @ R30 Suburban Air Filter Kit, R30 Wiring Diagram One - 52.codebluehacks.org said:

Pingback from  1987 - 1991 @ R30 Suburban Air Filter Kit, R30 Wiring Diagram One - 52.codebluehacks.org

# May 31, 2010 2:40 AM

1999 - 1980 @ Order Ascender Gear, Isuzu Ascender 7 - 284.luna-atra.net said:

Pingback from  1999 - 1980 @ Order Ascender Gear, Isuzu Ascender 7 - 284.luna-atra.net

# May 31, 2010 2:45 PM

1983 - 1994 @ Lx470 Tube Is250 Lexus Sc300, Lx470 Led Joist - 133.computeronlinebingo.com said:

Pingback from  1983 - 1994 @ Lx470 Tube Is250 Lexus Sc300, Lx470 Led Joist - 133.computeronlinebingo.com

# May 31, 2010 4:08 PM

1981 - 2007 @ Order 733i Brake Master Cylinder, 733i Statute Of Frauds - 446.renters.ws said:

Pingback from  1981 - 2007 @ Order 733i Brake Master Cylinder, 733i Statute Of Frauds - 446.renters.ws

# May 31, 2010 4:31 PM

Web site of the state - State web - Cincinnati state college web site said:

Pingback from  Web site of the state - State web - Cincinnati state college web site

# August 21, 2010 1:20 PM