Access Denied: Only an administrator may enumerate through all user profiles



I get the access denied error. I've looked at
http://edinkapic.blogspot.com/2007/08/enumerating-user-profiles.html and my
application pool is running under the administrator account and has all SSP
rights. It works if I run as the Administrator account but not a user with
Contribute rights. I've done other simple operations using the
RunWithElevatedPrivileges with user profiles but now I'm trying to enumerate
them and that's not working. My goal is to retrieve users with direct
reports.

Any help is much appreciated, my code is below.

Thanks
Brad

private void DoSomething()
{
SPSecurity.CodeToRunElevated code = new
SPSecurity.CodeToRunElevated(GetAllManagers);
SPSecurity.RunWithElevatedPrivileges(code);
}

private void GetAllManagers()
{
try
{
using (SPSite tempSite = new
SPSite(SPContext.Current.Site.ID))
{
Microsoft.Office.Server.ServerContext context =
ServerContext.GetContext(tempSite);
UserProfileManager upm = new
UserProfileManager(context);

foreach (UserProfile up in upm)
{
if (up.GetDirectReports().Length > 0)
{
managerList.Add(up["PreferredName"].ToString());
}
}
}

}
catch (Exception ex)
{
throw ex;
}

}


.



Relevant Pages

  • Re: UAC disabled same as "Run as administrator"?
    ... running with the same rights as a standard user. ... re-enable UAC, which is a way to duplicate, on Vista, the techniques ... machine could gain access to system items and cause serious damage. ... to an administrator account, and performing untold damage, the prompt ...
    (microsoft.public.windows.vista.administration_accounts_passwords)
  • Re: WinXP Pro security login flaw ?
    ... Most of the time the administrator account doesn't have a display name. ... This posting is provided "AS IS" with no warranties, and confers no rights. ... > MS MVP (Windows Platform), MCSE, MCDBA ...
    (microsoft.public.windowsxp.security_admin)
  • Re: Locking down the Domain Administrator Account
    ... Microsoft recommends renaming the Administrator account ... account called Administrator with almost no rights on the ... network so if a hacker gets the password it has no rights ...
    (microsoft.public.win2000.security)
  • Re: Adminstrator profile is the only one that can change the password?
    ... >> I set up a second profile and gave it admin rights... ... second user account the Administrator account is no longer seen. ...
    (microsoft.public.windowsxp.security_admin)
  • Re: Administrator rights
    ... You can not "overwrite" the built in administrator account and any user in ... the administrators group will have sufficient rights to do any task on the ... > I inadvertantly created another administrator account ... > Is there a way to bypass this security to reset admin ...
    (microsoft.public.win2000.security)