aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
diff options
context:
space:
mode:
authorDr Scofield2008-07-04 11:13:25 +0000
committerDr Scofield2008-07-04 11:13:25 +0000
commit6265a09ff90d1de4a09b41fbdcb99a1eb2ebc2d4 (patch)
tree9a70bf001c72897fac37d96812d2e66681c456b9 /OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
parentmini-warnings-safari, plus cleanup of IUserServices method naming. (diff)
downloadopensim-SC_OLD-6265a09ff90d1de4a09b41fbdcb99a1eb2ebc2d4.zip
opensim-SC_OLD-6265a09ff90d1de4a09b41fbdcb99a1eb2ebc2d4.tar.gz
opensim-SC_OLD-6265a09ff90d1de4a09b41fbdcb99a1eb2ebc2d4.tar.bz2
opensim-SC_OLD-6265a09ff90d1de4a09b41fbdcb99a1eb2ebc2d4.tar.xz
Renaming UserManagerBase.SetUserProfile(UserProfileData) to
UserManager.UpdateUserProfile(UserProfileData). Adding UpdateUserProfile(UserProfileData) to IUserService interface. Adding RemoteAdminPlugin.XmlRpcUpdateUserAccountMethod(...) to provide a remote update capability.
Diffstat (limited to 'OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs')
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs106
1 files changed, 106 insertions, 0 deletions
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
86 m_httpd.AddXmlRPCHandler("admin_restart", XmlRpcRestartMethod); 86 m_httpd.AddXmlRPCHandler("admin_restart", XmlRpcRestartMethod);
87 m_httpd.AddXmlRPCHandler("admin_load_heightmap", XmlRpcLoadHeightmapMethod); 87 m_httpd.AddXmlRPCHandler("admin_load_heightmap", XmlRpcLoadHeightmapMethod);
88 m_httpd.AddXmlRPCHandler("admin_create_user", XmlRpcCreateUserMethod); 88 m_httpd.AddXmlRPCHandler("admin_create_user", XmlRpcCreateUserMethod);
89 m_httpd.AddXmlRPCHandler("admin_update_user", XmlRpcUpdateUserAccountMethod);
89 m_httpd.AddXmlRPCHandler("admin_load_xml", XmlRpcLoadXMLMethod); 90 m_httpd.AddXmlRPCHandler("admin_load_xml", XmlRpcLoadXMLMethod);
90 } 91 }
91 } 92 }
@@ -564,6 +565,111 @@ namespace OpenSim.ApplicationPlugins.RemoteController
564 return response; 565 return response;
565 } 566 }
566 567
568 /// <summary>
569 /// Update the password of a user account.
570 /// <summary>
571 /// <param name="request">incoming XML RPC request</param>
572 /// <remarks>
573 /// XmlRpcUpdateUserAccountMethod takes the following XMLRPC
574 /// parameters
575 /// <list type="table">
576 /// <listheader><term>parameter name</term><description>description</description></listheader>
577 /// <item><term>password</term>
578 /// <description>admin password as set in OpenSim.ini</description></item>
579 /// <item><term>user_firstname</term>
580 /// <description>avatar's first name (cannot be changed)</description></item>
581 /// <item><term>user_lastname</term>
582 /// <description>avatar's last name (cannot be changed)</description></item>
583 /// <item><term>user_password</term>
584 /// <description>avatar's password (changeable)</description></item>
585 /// <item><term>start_region_x</term>
586 /// <description>avatar's start region coordinates, X
587 /// value (changeable)</description></item>
588 /// <item><term>start_region_y</term>
589 /// <description>avatar's start region coordinates, Y
590 /// value (changeable)</description></item>
591 /// </list>
592 ///
593 /// XmlRpcCreateUserMethod returns
594 /// <list type="table">
595 /// <listheader><term>name</term><description>description</description></listheader>
596 /// <item><term>success</term>
597 /// <description>true or false</description></item>
598 /// <item><term>error</term>
599 /// <description>error message if success is false</description></item>
600 /// </list>
601 /// </remarks>
602 public XmlRpcResponse XmlRpcUpdateUserAccountMethod(XmlRpcRequest request)
603 {
604 m_log.Info("[RADMIN]: UpdateUserAccount: new request");
605 XmlRpcResponse response = new XmlRpcResponse();
606 Hashtable responseData = new Hashtable();
607
608 try
609 {
610 Hashtable requestData = (Hashtable) request.Params[0];
611
612 // check completeness
613 checkStringParameters(request, new string[] { "password", "user_firstname",
614 "user_lastname" });
615
616 // check password
617 if (!String.IsNullOrEmpty(requiredPassword) &&
618 (string)requestData["password"] != requiredPassword) throw new Exception("wrong password");
619
620 // do the job
621 string firstname = (string) requestData["user_firstname"];
622 string lastname = (string) requestData["user_lastname"];
623
624
625 string passwd = String.Empty;
626 uint? regX = null;
627 uint? regY = null;
628
629 if (requestData.ContainsKey("user_password")) passwd = (string) requestData["user_password"];
630 if (requestData.ContainsKey("start_region_x")) regX = Convert.ToUInt32((Int32)requestData["start_region_x"]);
631 if (requestData.ContainsKey("start_region_y")) regY = Convert.ToUInt32((Int32)requestData["start_region_y"]);
632
633 if (String.Empty == passwd && null == regX && null == regY)
634 throw new Exception("neither user_password nor start_region_x nor start_region_y provided");
635
636 UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname);
637 if (null == userProfile)
638 throw new Exception(String.Format("avatar {0} {1} does not exist", firstname, lastname));
639
640 if (null != passwd)
641 {
642 string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(passwd) + ":" + String.Empty);
643 userProfile.PasswordHash = md5PasswdHash;
644 }
645
646 if (null != regX) userProfile.HomeRegionX = (uint)regX;
647 if (null != regY) userProfile.HomeRegionY = (uint)regY;
648
649 if (!m_app.CommunicationsManager.UserService.UpdateUserProfile(userProfile))
650 throw new Exception("did not manage to update user profile");
651
652 responseData["success"] = "true";
653
654 response.Value = responseData;
655
656 m_log.InfoFormat("[RADMIN]: UpdateUserAccount: account for user {0} {1} updated, UUID {2}", firstname, lastname,
657 userProfile.ID);
658 }
659 catch (Exception e)
660 {
661 m_log.ErrorFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.Message);
662 m_log.DebugFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.ToString());
663
664 responseData["success"] = "false";
665 responseData["error"] = e.Message;
666
667 response.Value = responseData;
668 }
669
670 return response;
671 }
672
567 public XmlRpcResponse XmlRpcLoadXMLMethod(XmlRpcRequest request) 673 public XmlRpcResponse XmlRpcLoadXMLMethod(XmlRpcRequest request)
568 { 674 {
569 m_log.Info("[RADMIN]: Received Load XML Administrator Request"); 675 m_log.Info("[RADMIN]: Received Load XML Administrator Request");