From 6265a09ff90d1de4a09b41fbdcb99a1eb2ebc2d4 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Fri, 4 Jul 2008 11:13:25 +0000 Subject: Renaming UserManagerBase.SetUserProfile(UserProfileData) to UserManager.UpdateUserProfile(UserProfileData). Adding UpdateUserProfile(UserProfileData) to IUserService interface. Adding RemoteAdminPlugin.XmlRpcUpdateUserAccountMethod(...) to provide a remote update capability. --- .../RemoteController/RemoteAdminPlugin.cs | 106 +++++++++++++++++++++ 1 file changed, 106 insertions(+) (limited to 'OpenSim/ApplicationPlugins/RemoteController') diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 2239001..e3a0321 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -86,6 +86,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController m_httpd.AddXmlRPCHandler("admin_restart", XmlRpcRestartMethod); m_httpd.AddXmlRPCHandler("admin_load_heightmap", XmlRpcLoadHeightmapMethod); m_httpd.AddXmlRPCHandler("admin_create_user", XmlRpcCreateUserMethod); + m_httpd.AddXmlRPCHandler("admin_update_user", XmlRpcUpdateUserAccountMethod); m_httpd.AddXmlRPCHandler("admin_load_xml", XmlRpcLoadXMLMethod); } } @@ -564,6 +565,111 @@ namespace OpenSim.ApplicationPlugins.RemoteController return response; } + /// + /// Update the password of a user account. + /// + /// incoming XML RPC request + /// + /// XmlRpcUpdateUserAccountMethod takes the following XMLRPC + /// parameters + /// + /// parameter namedescription + /// password + /// admin password as set in OpenSim.ini + /// user_firstname + /// avatar's first name (cannot be changed) + /// user_lastname + /// avatar's last name (cannot be changed) + /// user_password + /// avatar's password (changeable) + /// start_region_x + /// avatar's start region coordinates, X + /// value (changeable) + /// start_region_y + /// avatar's start region coordinates, Y + /// value (changeable) + /// + /// + /// XmlRpcCreateUserMethod returns + /// + /// namedescription + /// success + /// true or false + /// error + /// error message if success is false + /// + /// + public XmlRpcResponse XmlRpcUpdateUserAccountMethod(XmlRpcRequest request) + { + m_log.Info("[RADMIN]: UpdateUserAccount: new request"); + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable responseData = new Hashtable(); + + try + { + Hashtable requestData = (Hashtable) request.Params[0]; + + // check completeness + checkStringParameters(request, new string[] { "password", "user_firstname", + "user_lastname" }); + + // check password + if (!String.IsNullOrEmpty(requiredPassword) && + (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); + + // do the job + string firstname = (string) requestData["user_firstname"]; + string lastname = (string) requestData["user_lastname"]; + + + string passwd = String.Empty; + uint? regX = null; + uint? regY = null; + + if (requestData.ContainsKey("user_password")) passwd = (string) requestData["user_password"]; + if (requestData.ContainsKey("start_region_x")) regX = Convert.ToUInt32((Int32)requestData["start_region_x"]); + if (requestData.ContainsKey("start_region_y")) regY = Convert.ToUInt32((Int32)requestData["start_region_y"]); + + if (String.Empty == passwd && null == regX && null == regY) + throw new Exception("neither user_password nor start_region_x nor start_region_y provided"); + + UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname); + if (null == userProfile) + throw new Exception(String.Format("avatar {0} {1} does not exist", firstname, lastname)); + + if (null != passwd) + { + string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(passwd) + ":" + String.Empty); + userProfile.PasswordHash = md5PasswdHash; + } + + if (null != regX) userProfile.HomeRegionX = (uint)regX; + if (null != regY) userProfile.HomeRegionY = (uint)regY; + + if (!m_app.CommunicationsManager.UserService.UpdateUserProfile(userProfile)) + throw new Exception("did not manage to update user profile"); + + responseData["success"] = "true"; + + response.Value = responseData; + + m_log.InfoFormat("[RADMIN]: UpdateUserAccount: account for user {0} {1} updated, UUID {2}", firstname, lastname, + userProfile.ID); + } + catch (Exception e) + { + m_log.ErrorFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.Message); + m_log.DebugFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.ToString()); + + responseData["success"] = "false"; + responseData["error"] = e.Message; + + response.Value = responseData; + } + + return response; + } + public XmlRpcResponse XmlRpcLoadXMLMethod(XmlRpcRequest request) { m_log.Info("[RADMIN]: Received Load XML Administrator Request"); -- cgit v1.1