Merge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim

This commit is contained in:
Diva Canto
2010-03-26 13:14:32 -07:00
6 changed files with 73 additions and 28 deletions

View File

@@ -177,9 +177,46 @@ namespace OpenSim.Services.Connectors.SimianGrid
public bool SetPassword(UUID principalID, string passwd)
{
// TODO: Use GetIdentities to find the md5hash identity for principalID
// and then update it with AddIdentity
m_log.Error("[AUTH CONNECTOR]: Changing passwords is not implemented yet");
// Fetch the user name first
NameValueCollection requestArgs = new NameValueCollection
{
{ "RequestMethod", "GetUser" },
{ "UserID", principalID.ToString() }
};
OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean() && response["User"] is OSDMap)
{
OSDMap userMap = (OSDMap)response["User"];
string identifier = userMap["Name"].AsString();
if (!String.IsNullOrEmpty(identifier))
{
// Add/update the md5hash identity
requestArgs = new NameValueCollection
{
{ "RequestMethod", "AddIdentity" },
{ "Identifier", identifier },
{ "Credential", "$1$" + Utils.MD5String(passwd) },
{ "Type", "md5hash" },
{ "UserID", principalID.ToString() }
};
response = WebUtil.PostToService(m_serverUrl, requestArgs);
bool success = response["Success"].AsBoolean();
if (!success)
m_log.WarnFormat("[AUTH CONNECTOR]: Failed to set password for {0} ({1})", identifier, principalID);
return success;
}
}
else
{
m_log.Warn("[AUTH CONNECTOR]: Failed to retrieve identities for " + principalID + ": " +
response["Message"].AsString());
}
return false;
}