tags:

views:

314

answers:

1

Hi,

The following code is used in a custom WebPart, and for some reason it only works the first time it's executed on a page. After that it throws a SingleSignonCredsNotFoundException

Any help or suggestions to how to solve this problem is much appreciated.

public static SsoIdentity GetCredentials(string applicationName)
{
    try
    {
        ISsoProvider ssoProvider = SsoProviderFactory.GetSsoProvider();
        SsoCredentials credentials = ssoProvider.GetCredentials(applicationName);

        string[] tmp = ConvertSecurityStringToString(credentials.UserName).Split(new string[] { "\\" }, StringSplitOptions.RemoveEmptyEntries);
        string username = tmp[1];
        string domain = tmp[0];
        string password = ConvertSecurityStringToString(credentials.Password);

        SsoIdentity wi = new SsoIdentity(username, password, domain);

        return wi;
    }
    catch (SingleSignonCredsNotFoundException ex)
    {

    }
    catch (SingleSignonException ex)
    {

    }

    return null;
}
A: 

So apparently the problem was that I was impersonating the user I was getting from the sso credential store. But when I undo this, it returns to the identity of the application pool and next time GetCredentials is called it lokos up that user in the sso, and that is not necessarily a member of the sso application.

mortenbpost