예제 #1
0
 static public void CreateUser(string tenantName, string username, string password, string email)
 {
     try
     {
         AdamTenantManager adamManager = AdamConfigurationHelper.AdamManager;
         if (adamManager.UserExists(tenantName, username))
         {
             throw new AuthenticationException(string.Format("The user with name {0} already exists!", username));
         }
         adamManager.CreateUser(tenantName, username, password, email);
     }
     catch (Exception ex)
     {
         throw new AuthenticationException(ex.Message, ex);
     }
 }
예제 #2
0
        public void CreateUser()
        {
            try
            {
                IsAdministrator();

                string tenantName = "missionsky5";
                string username   = "******";
                string password   = "******";
                string email      = "*****@*****.**";

                using (new Impersonator("msadmin", "ms-dev3.cloudapp.net", "Msadm1n;"))
                {
                    AdamTenantManager adamManager = AdamConfigurationHelper.AdamManager;
                    adamManager.Username         = "******";
                    adamManager.Password         = "******";
                    adamManager.SecureConnection = true;

                    // adamManager.SecureConnection = true;
                    //adamManager.CreateTenant(tenantName);
                    adamManager.ValidateUser(tenantName, username, password);

                    if (adamManager.UserExists(tenantName, username))
                    {
                        throw new AuthenticationException(string.Format("The user with name {0} already exists!", username));
                    }
                    adamManager.CreateUser(tenantName, username, password, email);

                    adamManager.SetPassword(tenantName, username, password);
                    adamManager.ChangePassword(tenantName, username, password, password);
                }
            }
            catch (Exception ex)
            {
                throw new AuthenticationException(ex.Message, ex);
            }
        }