From 55dc0dc2670f0db384d7ff5bad3d810a08ffbd34 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 29 Jan 2008 14:43:45 +0000 Subject: [PATCH] * Patch from Ansi (IBM) * Allows the creation of a user via the RemoteAdminPlugin. * Many thanks! --- .../RemoteController/RemoteAdminPlugin.cs | 56 ++++++++++++++++++- OpenSim/Region/Application/OpenSimMain.cs | 5 ++ 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index fa76078e6f..770abe7138 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -67,6 +67,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions m_httpd.AddXmlRPCHandler("admin_broadcast", XmlRpcAlertMethod); m_httpd.AddXmlRPCHandler("admin_restart", XmlRpcRestartMethod); m_httpd.AddXmlRPCHandler("admin_load_heightmap", XmlRpcLoadHeightmapMethod); + m_httpd.AddXmlRPCHandler("admin_create_user", XmlRpcCreateUserMethod); } } catch (NullReferenceException) @@ -281,9 +282,60 @@ namespace OpenSim.ApplicationPlugins.LoadRegions return response; } + public XmlRpcResponse XmlRpcCreateUserMethod(XmlRpcRequest request) + { + MainLog.Instance.Verbose("RADMIN", "Received Create User Administrator Request"); + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable) request.Params[0]; + Hashtable responseData = new Hashtable(); + if (requiredPassword != System.String.Empty && + (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword)) + { + responseData["created"] = "false"; + response.Value = responseData; + } + else + { + try + { + string tempfirstname = (string) requestData["user_firstname"]; + string templastname = (string) requestData["user_lastname"]; + string tempPasswd = (string) requestData["user_password"]; + uint regX = Convert.ToUInt32((Int32) requestData["start_region_x"]); + uint regY = Convert.ToUInt32((Int32) requestData["start_region_y"]); + + LLUUID tempuserID = m_app.CreateUser(tempfirstname, templastname, tempPasswd, regX, regY); + + if (tempuserID == LLUUID.Zero) + { + responseData["created"] = "false"; + responseData["error"] = "Error creating user"; + responseData["avatar_uuid"] = LLUUID.Zero; + response.Value = responseData; + MainLog.Instance.Error("RADMIN", "Error creating user (" + tempfirstname + " " + templastname + ") :"); + } + else + { + responseData["created"] = "true"; + responseData["avatar_uuid"] = tempuserID; + response.Value = responseData; + MainLog.Instance.Verbose("RADMIN", "User " + tempfirstname + " " + templastname + " created. Userid " + tempuserID + " assigned."); + } + } + catch (Exception e) + { + responseData["created"] = "false"; + responseData["error"] = e.ToString(); + responseData["avatar_uuid"] = LLUUID.Zero; + response.Value = responseData; + } + } + + return response; + } + public void Close() { } - } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index a620bd4f35..f0e60cf887 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -436,6 +436,10 @@ namespace OpenSim m_sceneManager.OnRestartSim += handleRestartRegion; } + public LLUUID CreateUser(string tempfirstname, string templastname, string tempPasswd, uint regX, uint regY) + { + return m_commsManager.AddUser(tempfirstname,templastname,tempPasswd,regX,regY); + } public UDPServer CreateRegion(RegionInfo regionInfo) { @@ -678,6 +682,7 @@ namespace OpenSim m_log.Error(" alert [First] [Last] [Message] - send an alert to a user. Case sensitive."); m_log.Error(" alert general [Message] - send an alert to all users."); m_log.Error("backup - trigger a simulator backup"); + m_log.Error("create user - adds a new user"); m_log.Error("change-region [name] - sets the region that many of these commands affect."); m_log.Error("command-script [filename] - Execute command in a file."); m_log.Error("debug - debugging commands");