How to Map Single Sign-On Credentials
When you know that you have affiliated applications in your Enterprise Single Sign-On database, you can map the credentials for a user to that application. Mapping the credentials of the current user to an affiliated application requires that you use a combination of the ISSOMapper
and ISSOMapping
interfaces.
To map between an affiliated application and user credentials
Create new instances of
ISSOMapper
andISSOMapping
.Set the
ISSOMapping
properties to the relevant values.The relevant properties for
ISSOMapping
are the Microsoft Windows domain name of the user, the Windows user name, the name of the affiliated application, and the external user name.Create the mapping with a call to ISSOMapping.Create.
Calling
ISSOMapping.Create
propagates the local copy of the mapping out to the Enterprise Single Sign-On server.Set the credentials on the mapping with a call to
ISSOMapper.SetExternalCredentials
.Enable the mapping with a call to
ISSOMapping.Enable
.The following example shows how to add mapping between a specified Enterprise Single Sign-On application and a user.
public static bool AddMapping(string application, string user, string XU, string XP)
{
try
{
// Set mapping.
ISSOMapper mapper=new ISSOMapper();
ISSOMapping mapping=new ISSOMapping();
string username=user.Substring(user.IndexOf('\\')+1);
string userdomain=user.Substring(0, user.IndexOf('\\'));
mapping.WindowsDomainName=userdomain;
mapping.WindowsUserName=username;
mapping.ApplicationName=application;
mapping.ExternalUserName=XU;
mapping.Create(0);
// Set credentials.
string[] credentials=new string[]{XP};
mapper.SetExternalCredentials(application, XU, ref credentials);
mapping.Enable(0);
}
catch
{
return false;
}
return true;
}