From ec2970f6b4bae85ff3103451348bbe7314b6e47e Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Mon, 6 Oct 2008 09:42:31 +0000 Subject: [PATCH] adds admin_exists_user XmlRpc call. --- .../RemoteController/RemoteAdminPlugin.cs | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 6ffb8ec223..eaab61cc9d 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -92,6 +92,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_exists_user", XmlRpcUserExistsMethod); m_httpd.AddXmlRPCHandler("admin_update_user", XmlRpcUpdateUserAccountMethod); m_httpd.AddXmlRPCHandler("admin_load_xml", XmlRpcLoadXMLMethod); m_httpd.AddXmlRPCHandler("admin_save_xml", XmlRpcSaveXMLMethod); @@ -646,6 +647,79 @@ namespace OpenSim.ApplicationPlugins.RemoteController return response; } + + /// + /// Check whether a certain user account exists. + /// + /// incoming XML RPC request + /// + /// XmlRpcUserExistsMethod takes the following XMLRPC + /// parameters + /// + /// parameter namedescription + /// password + /// admin password as set in OpenSim.ini + /// user_firstname + /// avatar's first name + /// user_lastname + /// avatar's last name + /// + /// + /// XmlRpcCreateUserMethod returns + /// + /// namedescription + /// user_firstname + /// avatar's first name + /// user_lastname + /// avatar's last name + /// success + /// true or false + /// error + /// error message if success is false + /// + /// + public XmlRpcResponse XmlRpcUserExistsMethod(XmlRpcRequest request) + { + m_log.Info("[RADMIN]: UserExists: 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"}); + + string firstname = (string) requestData["user_firstname"]; + string lastname = (string) requestData["user_lastname"]; + + UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname); + + responseData["user_firstname"] = firstname; + responseData["user_lastname"] = lastname; + + if (null == userProfile) + responseData["success"] = false; + else + responseData["success"] = true; + + response.Value = responseData; + } + catch (Exception e) + { + m_log.ErrorFormat("[RADMIN] UserExists: failed: {0}", e.Message); + m_log.DebugFormat("[RADMIN] UserExists: failed: {0}", e.ToString()); + + responseData["success"] = "false"; + responseData["error"] = e.Message; + + response.Value = responseData; + } + + return response; + } + /// /// Update the password of a user account. ///