Exemple #1
0
        /// <summary>
        /// Provision the user
        /// </summary>
        /// <returns>new Hostnode if successful, otherwise null</returns>
        public string ProvisionUser(string Username)
        {
            HostNode hostnode = null;
            Member   member   = domain.GetMemberByName(Username);

            if (member != null)
            {
                hostnode = member.HomeServer;
                if (hostnode == null)
                {
                    HostEntry hostentry = hosts[0] as HostEntry;
                    hostnode = hostentry.Host;
                    hostentry.AddMember(domain, member);
                    lock ( hosts )
                    {
                        hosts.Sort();
                    }
                }
            }

            return(hostnode == null ? null : hostnode.UserID);
        }
Exemple #2
0
        /// <summary>
        /// Provision the user based on userID and HostName
        /// </summary>
        /// <returns>New hostInfo if successful otherwise null</returns>
        public static Simias.Host.HostInfo ProvisionUser(string userID, string hostName)
        {
            log.Debug("ProvisionUser: Request for  {0} to {1}", userID, hostName);
            HostNode hostnode = null;
            Store    store    = Store.GetStore();
            Domain   domain   = store.GetDomain(store.DefaultDomain);
            Member   member   = domain.GetMemberByID(userID);

            log.Debug(String.Format("ProvisionUser {0}", userID));
            hostnode = checkUserProvisionedByID(userID);
            if (hostnode == null)
            {
                hostnode = HostNode.GetHostByName(domain.ID, hostName);
                if (hostnode == null)
                {
                    return(null);
                }
                log.Debug(String.Format("Setting the home server for {0} to {1}", userID, hostName));
                HostEntry hentry = new HostEntry(hostnode);
                hostnode = hentry.Host;
                hentry.AddMember(domain, member);
            }
            else
            {
                if (Simias.Service.Manager.UserMoveServiceEnabled == false)
                {
                    log.Debug(String.Format("User move service is not configured, User movement skipped for  {0} to {1}", userID, hostName));
                    throw new Exception(String.Format("User move service is not configured, User movement skipped for  {0} to {1}", userID, hostName));
                }
                hostnode = HostNode.GetHostByName(domain.ID, hostName);
                if (hostnode == null)
                {
                    return(null);
                }
                return(Simias.Server.UserMove.Reprovision(userID, HostNode.GetMaster(domain.ID), member.HomeServer, hostnode));
            }
            return(new Simias.Host.HostInfo(hostnode));
        }