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:

Currently rated 1.5 by 20 people

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

Related posts

Add comment


 

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

May 19. 2012 11:47