public string osAvatarName2Key(string firstname, string lastname)
{
CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key");
m_host.AddScriptLPS(1);
IUserManagement userManager = World.RequestModuleInterface<IUserManagement>();
if (userManager == null)
{
OSSLShoutError("osAvatarName2Key: UserManagement module not available");
return string.Empty;
}
// Check if the user is already cached
UUID userID = userManager.GetUserIdByName(firstname, lastname);
if (userID != UUID.Zero)
return userID.ToString();
// Query for the user
String realFirstName; String realLastName; String serverURI;
if (Util.ParseForeignAvatarName(firstname, lastname, out realFirstName, out realLastName, out serverURI))
{
try
{
UserAgentServiceConnector userConnection = new UserAgentServiceConnector(serverURI, true);
if (userConnection != null)
{
userID = userConnection.GetUUID(realFirstName, realLastName);
if (userID != UUID.Zero)
{
userManager.AddUser(userID, realFirstName, realLastName, serverURI);
return userID.ToString();
}
}
}
catch (Exception /*e*/)
{
// m_log.Warn("[osAvatarName2Key] UserAgentServiceConnector - Unable to connect to destination grid ", e);
}
}
else
{
UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, firstname, lastname);
if (account != null)
return account.PrincipalID.ToString();
}
return UUID.Zero.ToString();
}