2011-08-10 15 views
1

사이트에서 다른 사용자 (즉, 이벤트를 트리거 한 사용자)의 사용자 프로필을 업데이트해야하는 SharePoint 2010 이벤트 수신기가 있습니다. 사용자 프로필 관리자의 사용자 토큰 (another question에서 제안한대로)을 사용하여 UserProfileManager를 열려고 시도하지만 어떤 이유로 인해 이벤트를 트리거 한 사람의 계정으로 계속 실행 중입니다.
사용자 프로필 서비스 응용 프로그램 관리자를 가장하여 사용자 프로필을 편집 할 수있는 올바른 방법은 무엇입니까?사용자 프로필 관리자로 SP2010 사용자 프로필 관리

SPUserToken upmToken = web.AllUsers[@"domain\upadmin"].UserToken;//this user is a User Profile Service Application Administrator 
using (SPSite upmSite = new SPSite(web.Url, upmToken)) 
{ 
    SPServiceContext context = SPServiceContext.GetContext(upmSite); 
    UserProfileManager userProfileManager = new UserProfileManager(context, false); 
    UserProfile userProfile = userProfileManager.GetUserProfile("anotheruser"); 
    userProfile["PictureUrl"].Value = pictureUrl;//System.UnauthorizedAccessException: Attempted to perform an unauthorized operation 
    userProfile.Commit(); 
} 

나는 사용자 프로필 서비스 응용 프로그램 관리자에 자신을 추가하는 경우가 분명히 여전히 이벤트 수신기를 트리거 한 사용자의 계정으로 UserProfileManager을 열려고 때문에, 코드가 잘 실행됩니다.
RunWithElevatedPermissions를 사용하기 위해 사용자 프로필 관리자에게 앱 풀 계정을 추가하는 것이 허용되지 않는다고 생각합니다.

답변

0

시스템 계정 토큰 (SPUserToken.SystemAccount)을 사용해 보셨습니까? using (SPSite mySiteSite = 새 SPSite (mySiteHostUrl, SPUserToken.SystemAccount))

관련 문제