Iterating UserProfiles in Shared Service Provider (SSP)
This article deals with retrieving user profiles of all the user that exists in shared service provider. There may be many scenarios where you need to iterate through all the userprofiles that exist in ssp. There is no such method available out of the box in MOSS where you can get list of user in Shared Service Provider. In order to iterate each profile in shared service provider we need to use Ienumerators
I had a scenario where I need to activate features on all the mysites that exist. In order to activate feature on individuals mysite, I first need to check whether the user has a mysite and then activate the feature.
When you are trying to do this you may come across some Permission and Access Denied exception. Here is the links which will help you to solve the issue
http://edinkapic.blogspot.com/2007/08/enumerating-user-profiles.html
You can retrieve users from SSP by using web services. The below code iterates a list of user from SSP
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Web;
using System.Collections;
using System.IO;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.Office.Server;
using Microsoft.Office.Server.UserProfiles;
public namespace SSPUsers
{
public class Program
{
static void Main(string[] args)
{
using (SPSite searchSite = new SPSite("http://sspsiteurl"))
{
UserProfile currentProfile;
bool checkPersonalSite;
// Use the ServerContext to get the SSP associated to the site collection of interest
ServerContext context = ServerContext.GetContext(searchSite);
// Get the user profile enumerator for the targeted SSP
UserProfileManager profileManager = new UserProfileManager(context);
long count = profileManager.Count;
IEnumerator enumerator = profileManager.GetEnumerator();
bool continueEnum = true;
while (continueEnum)
{
try
{
continueEnum = enumerator.MoveNext();
}
catch (Exception e)
{
Console.WriteLine("EXCEPTION in enum - try to move to next: " + e.ToString());
continueEnum = enumerator.MoveNext();
}
currentProfile = (UserProfile)enumerator.Current;
}
}
}
The currentProfile object will give you access to all the properties of a user availabel in the ssp