Quantcast
Channel: SharePoint 2013 - General Discussions and Questions forum
Viewing all articles
Browse latest Browse all 26374

UserProfileApplicationNotAvailableException_Logging

$
0
0

I'am facing a random exception on getting property from User Profile. All things seems to work fine and all the configuration are set with the right way. proceeding to An IIS reset resolve the problem. The exception message is userProfileApplicationNotAvailableException_Logging :: UserProfileApplicationProxy.ApplicationProperties ProfilePropertyCache does not have [Guid-Value]

My code is

public static string GetUserProfileProperty(SPWeb web, string property, string loginName)
    {
        SPUserToken token = web.Site.SystemAccount.UserToken;
        Guid siteId = web.Site.ID;
        string propertyValue = string.Empty;
        SPSecurity.RunWithElevatedPrivileges(delegate()
        {

            try
            {
                using (SPSite site = new SPSite(siteId, token))
                {
                    SPServiceContext context = SPServiceContext.GetContext(site);
                    UserProfileManager profileManager = new UserProfileManager(context);
                    if (profileManager.UserExists(loginName))
                    {
                        UserProfile profile = profileManager.GetUserProfile(loginName);
                        if (profile[property] == null)
                            throw new Exception("Erreur Property " + profile + " not exist  ");
                        if (profile[property].Value != null)
                            propertyValue = profile[property].Value.ToString();
                    }
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
        });

        return propertyValue;

    }

The distribued cache account have full permission on User profile Synchronisation Service application. The Application Pool account of the web application have full permission on UPS application too.

Is there anyone who got the same problem ?



Viewing all articles
Browse latest Browse all 26374

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>