Beispiel #1
0
        // This will cache the user data
        // Change this to return bool
        private bool GetUserInfo(UUID userID)
        {
            UserData userdata;

            lock (m_UserCache)
                m_UserCache.TryGetValue(userID, out userdata);

            if (userdata != null)
            {
//                m_log.DebugFormat("[USER MANAGEMENT MODULE]: Requested url type {0} for {1}", serverType, userID);

                if (userdata.Flags >= 0)
                {
                    // This is already populated
                    return(true);
                }

                if (userdata.HomeURL != null && userdata.HomeURL != string.Empty)
                {
                    m_log.DebugFormat(
                        "[USER MANAGEMENT MODULE]: Requesting user flags from '{0}' for {1}",
                        userdata.HomeURL, userID);

                    UserAgentServiceConnector   uConn = new UserAgentServiceConnector(userdata.HomeURL);
                    Dictionary <string, object> info  = uConn.GetUserInfo(userID);

                    // Pull our data now
                    if (info["result"].ToString() == "success")
                    {
                        userdata.Flags   = (int)info["user_flags"];
                        userdata.Created = (int)info["user_created"];
                        userdata.Title   = (string)info["user_title"];

                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #2
0
        //
        // Get the UserAccountBits
        //
        private bool GetUserProfileData(UUID userID, out Dictionary <string, object> userInfo)
        {
            IUserManagement             uManage = UserManagementModule;
            Dictionary <string, object> info    = new Dictionary <string, object>();


            if (!uManage.IsLocalGridUser(userID))
            {
                // Is Foreign
                string home_url = uManage.GetUserServerURL(userID, "HomeURI");

                if (String.IsNullOrEmpty(home_url))
                {
                    info["user_flags"]   = 0;
                    info["user_created"] = 0;
                    info["user_title"]   = "Unavailable";

                    userInfo = info;
                    return(true);
                }

                UserAgentServiceConnector uConn = new UserAgentServiceConnector(home_url);

                Dictionary <string, object> account = uConn.GetUserInfo(userID);

                if (account.Count > 0)
                {
                    if (account.ContainsKey("user_flags"))
                    {
                        info["user_flags"] = account["user_flags"];
                    }
                    else
                    {
                        info["user_flags"] = "";
                    }

                    if (account.ContainsKey("user_created"))
                    {
                        info["user_created"] = account["user_created"];
                    }
                    else
                    {
                        info["user_created"] = "";
                    }

                    info["user_title"] = "HG Visitor";
                }
                else
                {
                    info["user_flags"]   = 0;
                    info["user_created"] = 0;
                    info["user_title"]   = "HG Visitor";
                }
                userInfo = info;
                return(true);
            }
            else
            {
                // Is local
                Scene scene                 = m_Scenes[0];
                IUserAccountService uas     = scene.UserAccountService;
                UserAccount         account = uas.GetUserAccount(scene.RegionInfo.ScopeID, userID);

                info["user_flags"]   = account.UserFlags;
                info["user_created"] = account.Created;

                if (!String.IsNullOrEmpty(account.UserTitle))
                {
                    info["user_title"] = account.UserTitle;
                }
                else
                {
                    info["user_title"] = "";
                }

                userInfo = info;

                return(false);
            }
        }
        /// <summary>
        /// Gets the user account data.
        /// </summary>
        /// <returns>
        /// The user profile data.
        /// </returns>
        /// <param name='userID'>
        /// If set to <c>true</c> user I.
        /// </param>
        /// <param name='userInfo'>
        /// If set to <c>true</c> user info.
        /// </param>
        private bool GetUserAccountData(UUID userID, out Dictionary <string, object> userInfo)
        {
            Dictionary <string, object> info = new Dictionary <string, object>();

            if (UserManagementModule.IsLocalGridUser(userID))
            {
                // Is local
                IUserAccountService uas     = Scene.UserAccountService;
                UserAccount         account = uas.GetUserAccount(Scene.RegionInfo.ScopeID, userID);

                info["user_flags"]   = account.UserFlags;
                info["user_created"] = account.Created;

                if (!String.IsNullOrEmpty(account.UserTitle))
                {
                    info["user_title"] = account.UserTitle;
                }
                else
                {
                    info["user_title"] = "";
                }

                userInfo = info;

                return(false);
            }
            else
            {
                // Is Foreign
                string home_url = UserManagementModule.GetUserServerURL(userID, "HomeURI");

                if (String.IsNullOrEmpty(home_url))
                {
                    info["user_flags"]   = 0;
                    info["user_created"] = 0;
                    info["user_title"]   = "Unavailable";

                    userInfo = info;
                    return(true);
                }

                UserAgentServiceConnector uConn = new UserAgentServiceConnector(home_url);

                Dictionary <string, object> account;
                try
                {
                    account = uConn.GetUserInfo(userID);
                }
                catch (Exception e)
                {
                    m_log.Debug("[PROFILES]: GetUserInfo call failed ", e);
                    account = new Dictionary <string, object>();
                }

                if (account.Count > 0)
                {
                    if (account.ContainsKey("user_flags"))
                    {
                        info["user_flags"] = account["user_flags"];
                    }
                    else
                    {
                        info["user_flags"] = "";
                    }

                    if (account.ContainsKey("user_created"))
                    {
                        info["user_created"] = account["user_created"];
                    }
                    else
                    {
                        info["user_created"] = "";
                    }

                    info["user_title"] = "HG Visitor";
                }
                else
                {
                    info["user_flags"]   = 0;
                    info["user_created"] = 0;
                    info["user_title"]   = "HG Visitor";
                }
                userInfo = info;
                return(true);
            }
        }