- Implement IProfileProvider.Initialize
Initialize() allows the profile service
to initialize a session and create a connection to the back-end repository.
The method is passed two objects from the portal: PropertyList and ProfileInfo. PropertyList is
the list of attributes mapped to properties on the Property
Map page of the Profile Source object in the portal. ProfileInfo is a set of name-value pairs, populated with
information entered in the portal Service Configuration
Interface (SCI) editor by a portal administrator. Typically,
this is information such as credentials for connecting to the back-end
system.
Java:
private String[] m_propertyList;
protected String[] getPropertyList()
{
return m_propertyList;
}
public void initialize(String[] propertyList,
ProfileInfo profileInfo)
throws ServiceException
{
this.m_propertyList = propertyList;
}
C#:
private string[] m_propertyList;
internal string[] GetPropertyList()
{
return m_propertyList;
}
public void Initialize(string[] PropertyList,
ProfileInfo ProfileSourceInfo)
{
this.m_propertyList = PropertyList;
}
In this example profile service, the PropertyList is stored in the m_propertyList member variable,
where it can later be accessed by the IUser implementation.
The IUser implementation requires the PropertyList to determine which properties to retrieve.
- Implement IProfileProvider.GetGlobalSignature
GetGlobalSignature() allows the portal to
determine whether profile information for any of the users has changed.
The portal compares the string returned from GetGlobalSignature() with the string returned from GetGlobalSignature() during the previous run of the profile service job. If the two strings
match, the job stops. The IDK does not enforce any restrictions on
the string used for the global signature; it can be a last-modified
date, a random number, or another identifier.
Java:
public String getGlobalSignature()
throws ServiceException
{
return new Date().toString();
}
C#:
public string GetGlobalSignature()
{
return System.DateTime.Now.Ticks.ToString();
}
This profile service returns a string representation
of the current date and time. This ensures the job will continue to AttachToUser().
- Implement IProfileProvider.AttachToUser
AttachToUser() is called for each user within
the group or groups configured in the Profile Source editor in the
portal. The first three parameters passed to AttachToUser() identify which user the profile service should retrieve from the
back-end system:
- UserID: The portal user ID. Can be used via
the PRC to look up other user attributes.
- LoginName: The portal login name. If this
user was added using an authentication service, this value corresponds
to ChildUser.UserName.
- UniqueName: Usually the name used to look
up the user in the back-end system. If the user was added using an
authentication service, this value corresponds to ChildUser.UserUniqueName.
If these parameters do not identify a valid user, a NoSuchUserException should be thrown.
The final parameter, LastSignature, is the signature returned by IUser.GetUserSignature() during the previous job.
Java:
public IUser attachToUser(int userId, String loginName,
String uniqueName, String lastSignature)
throws ServiceException
{
return new User(this);
}
C#:
public IUser AttachToUser(int UserID, string LoginName,
string UniqueName, string LastSignature)
{
return new User(this);
}
For this profile service, AttachToUser() simply returns an instance of User, the IUser implementation. This is appropriate for this implementation
because the profile service updates the "Region" property to "WEST"
regardless of the portal user being queried.
- Implement IProfileProvider.Shutdown
As a performance optimization, the portal might call the Shutdown() method. No parameters are received or returned.
This method is optional on both ends; the profile service might not
receive the Shutdown message, and, if received, the profile service
can ignore the call to Shutdown().
Shutdown() can be used to clean up resources used by the
profile service; however, you should not rely on it being called.