Exemplo n.º 1
0
        public object Get(GetOneUsers request)
        {
            List <WebOneUser> result = new List <WebOneUser>();

            var context = TepWebContext.GetWebContext(PagePrivileges.AdminOnly);

            try {
                context.Open();
                context.LogInfo(this, string.Format("/one/user GET ProviderId='{0}'", request.ProviderId));
                int provId = (request.ProviderId != 0 ? request.ProviderId : context.GetConfigIntegerValue("One-default-provider"));
                OneCloudProvider oneCloud = (OneCloudProvider)CloudProvider.FromId(context, provId);
                USER_POOL        pool     = oneCloud.XmlRpc.UserGetPoolInfo();
                foreach (object u in pool.Items)
                {
                    if (u is USER_POOLUSER)
                    {
                        USER_POOLUSER oneuser = u as USER_POOLUSER;
                        WebOneUser    wu      = new WebOneUser {
                            Id = oneuser.ID, Name = oneuser.NAME, Password = oneuser.PASSWORD, AuthDriver = oneuser.AUTH_DRIVER
                        };
                        result.Add(wu);
                    }
                }
                context.Close();
            } catch (Exception e) {
                context.LogError(this, e.Message, e);
                context.Close();
                throw e;
            }
            return(result);
        }
Exemplo n.º 2
0
        //---------------------------------------------------------------------------------------------------------------------

        public void StartDelegate(string username)
        {
            USER_POOL users = xmlrpc.UserGetPoolInfo();

            foreach (object user in users.Items)
            {
                if (user.GetType() == typeof(USER_POOLUSER))
                {
                    if (((USER_POOLUSER)user).NAME.Equals(username))
                    {
                        xmlrpc.StartDelegate(username);
                        return;
                    }
                }
            }
            throw new Exception(String.Format("User {0} not found on One Cloud Provider", username));
        }
Exemplo n.º 3
0
        public object Get(GetOneCurrentUser request)
        {
            WebOneUser result = new WebOneUser();

            var context = TepWebContext.GetWebContext(PagePrivileges.UserView);

            try {
                context.Open();
                context.LogInfo(this, string.Format("/one/user/current GET ProviderId='{0}'", request.ProviderId));
                int    provId   = (request.ProviderId != 0 ? request.ProviderId : context.GetConfigIntegerValue("One-default-provider"));
                User   user     = User.FromId(context, context.UserId);
                string username = user.Email;
                try{
                    CloudUser usercloud = CloudUser.FromIdAndProvider(context, context.UserId, provId);
                    if (!String.IsNullOrEmpty(usercloud.CloudUsername))
                    {
                        username = usercloud.CloudUsername;
                    }
                }catch (Exception) {}

                OneCloudProvider oneCloud = (OneCloudProvider)CloudProvider.FromId(context, provId);
                USER_POOL        pool     = oneCloud.XmlRpc.UserGetPoolInfo();
                foreach (object u in pool.Items)
                {
                    if (u is USER_POOLUSER)
                    {
                        USER_POOLUSER oneuser = u as USER_POOLUSER;
                        if (oneuser.NAME == username)
                        {
                            result = new WebOneUser {
                                Id = oneuser.ID, Name = oneuser.NAME, Password = oneuser.PASSWORD, AuthDriver = oneuser.AUTH_DRIVER
                            };
                            break;
                        }
                    }
                }

                context.Close();
            } catch (Exception e) {
                context.LogError(this, e.Message, e);
                context.Close();
                throw e;
            }
            return(result);
        }