User Cannot Be Found?!

Upon import of a user's profile (from AD), the user is still not recognized as a 'bonafide' SharePoint account until they actually login (authenticate) to the SharePoint site. Consequently, if you're attempting to write code that iterates thru a group of users and programmatically sets their profile image - that code will fail for any user who has not logged into the SharePoint site (and will throw the infamous 'User Cannot Be Found' exception). I stumbled onto this issue when working with a new MOSS site, so most users had not yet logged in. I resolved the issue by calling SPWeb.EnsureUser(username) - (http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.ensureuser.aspx) before attempting to access the user object. This method requires elevated permissions to run.
Happy Coding!

Posted on 12/16/2009 6:49:00 AM by sterlingt

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: MOSS 2007 | SharePoint 2007 | WSS 3.0

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

SharePoint Rounded Corner Web Parts

Use JQuery and a content editor web part to quickly achieve rounded corner backgrounds for web parts within SharePoint 2007.

QuickStart Guide
  1. Generate images for web part corners - I used http://www.roundedcornr.com.
  2. Copy/paste the following JavaScript content into a text editor - RoundedWebPart.js (2.20 kb)
  3. Replace the following corner image URL's with paths to your newly generated corner images (ensure your users have 'read' privileges to the images' location)
    • /Shared%20Pictures/Top_Left_Corner.png
    • /Shared%20Pictures/Top_Right_Corner.png
    • /Shared%20Pictures/Bottom_Left_Corner.png
    • /Shared%20Pictures/Bottom_Right_Corner.png
  4. Replace the '#f3de96' color with the value of your images' color
  5. Add a Content Editor Web Part to the SharePoint page
  6. Modify the Web Part and paste your modified JavaScript text content into the Source Code Editor
Check the content editor's layout 'Hidden' property to prevent it from displaying with a rounded corner background.

Posted on 12/8/2009 5:02:00 PM by sterlingt

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: MOSS 2007 | SharePoint 2007 | WSS 3.0

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

WSS 3.0 Subsite Display Web Part

Need to display a list of 'child' site hyperlinks within a web part in WSS 3.0? Me, too - so I wrote a web part to do it. Why on earth would Microsoft leave such necessary and elementary functionality out of WSS 3.0? That's easy, to give me something (else) to do in my spare time. ;-)

Web Part Solution File - ChildSiteDisplay.wsp (4.14 kb)
Web Part Source Code - ChildSiteDisplay.zip (438.08 kb)


Posted on 11/9/2009 12:07:00 PM by sterlingt

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: SharePoint 2007 | SharePoint 2007 Features | WSS 3.0

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Role Based Web Part Personalization

I felt compelled to blog on this topic since I had a heck of a time finding any decent documentation on it. What finally pointed me in the right direction after hours of hunting was this random info nugget.

Here's what I had: A dashboard/portal page with operable web part per-user personalization. However, I have multiple roles within my site (not using Asp.net built-in roles, but my own custom provider). When users hit my dashboard page, their role was variable depending on the query string parameters present. Sometimes users should see certain web parts and other times be limited to other web parts. So what I needed was a way to dynamically evaluate within the code-behind whether to actually display a web part contained within that user's aspnet_PersonalizationPerUser record entry.

Thank-you, WebPartManager.AuthorizeWebPart event:

protected void MyWebPartManager1_AuthorizeWebPart(object sender, WebPartAuthorizationEventArgs e)
{
if (!String.IsNullOrEmpty(e.AuthorizationFilter))
{
if (e.AuthorizationFilter.ToString().Equals("Admin"))
{
if (UserIsAdmin())
e.IsAuthorized = false;
}
else if (e.AuthorizationFilter.ToString().Equals("Student"))
{
if (UserIsStudent())
e.IsAuthorized = false;
}
}
}


Now to populate the web part AuthorizationFilter attribute appropriately. This is fairly straight-forward if you're declaratively adding web parts to your CatalogZone and/or WebPartZone, simply add the AuthorizationFilter attribute into the declarative web part statement. However, if like me you're dynamically populating a DeclarativeCatalogPart using the WebPartsListUserControlPath property - you'll need to add the attribute to your user control declaration within the WebPartsListUserControlPath file:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="AdminWebParts.ascx.cs" Inherits="AdminWebParts" %>
<%@ Register TagPrefix="uc" TagName="adminuc" Src="~\AdministrationUC.ascx" %>


Once the attribute is added to the user control declaration, you should be able to access its value (if any) within the WebPartManager.AuthorizeWebPart event. One little gotcha to keep in mind when working with personalization and web parts. If you've already added web parts to the profile of an existing user prior to making the changes described here, the attribute won't exist. You need to delete all existing web parts within that user's profile, and add new ones after you've added the relevant AuthorizationFilter attribute.

Posted on 7/6/2009 11:22:00 AM by sterlingt

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: asp.NET 2.0 | MOSS 2007 | SharePoint 2007 | WSS 3.0

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Daily Head-Banger - Multiple Authentication (FBA) with SharePoint 2007

Having trouble getting your SharePoint 2007 extranet implementation with forms authentication to see your AspMembership users? Can't for the LIFE of you figure out why?? Try this on for size (of the half dozen articles I consulted in this effort, ALL of them left the following steps out):
  • Be sure to allocate db_owner privileges on your AspMembership database to your Central Admin's application pool account
  • Be sure to add your extranet's application pool account to your AspMembership database's users
  • In your web.config edits, be sure to list the membership and roleManager properties after the FIRST opening system.web tag (there's 3 total in the web.config documents.)
Happy Coding!!

**For all you MOSS fanatics, I'll be posting my own custom detailed instructions on installation/configuration of a Medium server MOSS farm, complete with detailed user security account best practices, and lots and lots of "gotcha's" I've discovered during my installation/configuration journey - stay tuned!!

Posted on 2/3/2009 10:38:00 AM by sterlingt

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: MOSS 2007 | SharePoint 2007 | WSS 3.0

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5