Access Denied: Only an administrator may enumerate through all user profiles
- From: "Brad Covell" <brad.covell@xxxxxxx>
- Date: Mon, 17 Dec 2007 10:53:28 -0500
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;
}
}
.
- Prev by Date: Re: MOSS 2007: How to create a grouped links list that dynamically expands when you click on the cell.
- Next by Date: Re: Drop Down List in Web Part Help!!
- Previous by thread: Searching sharepoint user criteria
- Next by thread: Re: Drop Down List in Web Part Help!!
- Index(es):
Relevant Pages
|