Add "friends show cache <first-name> <last-name>" command for debugging purposes.

This adds a reverse lookup (name -> ID) to IUserManagement instead of hitting the UserAccountService directly.
This commit is contained in:
Justin Clark-Casey (justincc)
2012-03-28 02:51:34 +01:00
parent 445e8bc560
commit 12d3ea3029
3 changed files with 120 additions and 2 deletions

View File

@@ -297,6 +297,35 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
#region IUserManagement
public UUID GetUserIdByName(string name)
{
string[] parts = name.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length < 2)
throw new Exception("Name must have 2 components");
return GetUserIdByName(parts[0], parts[1]);
}
public UUID GetUserIdByName(string firstName, string lastName)
{
// TODO: Optimize for reverse lookup if this gets used by non-console commands.
lock (m_UserCache)
{
foreach (UserData user in m_UserCache.Values)
{
if (user.FirstName == firstName && user.LastName == lastName)
return user.Id;
}
}
UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName);
if (account != null)
return account.PrincipalID;
return UUID.Zero;
}
public string GetUserName(UUID uuid)
{
string[] names = GetUserNames(uuid);