예제 #1
0
        public virtual void UpdateAccount(MailAccount mailbox)
        {
            try
            {
                //get original account
                MailAccount account = GetAccount(mailbox.Name);

                svcUserAdmin users = new svcUserAdmin();
                PrepareProxy(users);

                GenericResult1 result = users.UpdateUser(AdminUsername, AdminPassword,
                    mailbox.Name,
                    mailbox.Password,
                    mailbox.FirstName,
                    mailbox.LastName,
                    account.IsDomainAdmin
                    );

                if (!result.Result)
                    throw new Exception(result.Message);

                // set additional settings
                result = users.SetRequestedUserSettings(AdminUsername, AdminPassword,
                    mailbox.Name,
                    new string[]
                    {
                        "isenabled=" + mailbox.Enabled,
                        "maxsize=" + (mailbox.MaxMailboxSize),
                        "passwordlocked=" + mailbox.PasswordLocked,
                        "replytoaddress=" + (mailbox.ReplyTo ?? ""),
                        "signature=" + (mailbox.Signature ?? "")
                    });

                if (!result.Result)
                    throw new Exception(result.Message);

                // set forwarding settings
                result = users.UpdateUserForwardingInfo(AdminUsername, AdminPassword,
                    mailbox.Name, mailbox.DeleteOnForward,
                    (mailbox.ForwardingAddresses != null ? String.Join(", ", mailbox.ForwardingAddresses) : ""));

                if (!result.Result)
                    throw new Exception(result.Message);

                // set autoresponder settings
                result = users.UpdateUserAutoResponseInfo(AdminUsername, AdminPassword,
                    mailbox.Name,
                    mailbox.ResponderEnabled,
                    (mailbox.ResponderSubject ?? ""),
                    (mailbox.ResponderMessage ?? ""));

                if (!result.Result)
                    throw new Exception(result.Message);
            }
            catch (Exception ex)
            {
                throw new Exception("Could not update mailbox", ex);
            }
        }
예제 #2
0
		public void UpdateAccount(MailAccount mailbox)
		{

			try
			{
				//get original account
				MailAccount account = GetAccount(mailbox.Name);

				svcUserAdmin users = new svcUserAdmin();
				PrepareProxy(users);

				string strPassword = mailbox.Password;

				//Don't change password. Get it from mail server.
				if (!mailbox.ChangePassword)
				{
					strPassword = account.Password;
				}

				GenericResult result = users.UpdateUser(
					AdminUsername, AdminPassword, mailbox.Name, strPassword, mailbox.FirstName, mailbox.LastName, mailbox.IsDomainAdmin);

			    if (!result.Result)
			    {
			        if (result.ResultCode == -21)
                        throw new Exception("Password doesn't meet complexity", new Exception(result.Message));
			        
                    throw new Exception(result.Message);
			    }

			    // set forwarding settings
				result = users.UpdateUserForwardingInfo(AdminUsername, AdminPassword,
					mailbox.Name, mailbox.DeleteOnForward,
					(mailbox.ForwardingAddresses != null ? String.Join(", ", mailbox.ForwardingAddresses) : ""));

				if (!result.Result)
					throw new Exception(result.Message);

				// Set additional settings
				result = users.SetRequestedUserSettings(AdminUsername, AdminPassword, mailbox.Name, mailbox.PrepareSetRequestedUserSettingsWebMethodParams());

				if (!result.Result)
					throw new Exception(result.Message);

				// set autoresponder settings
				result = users.UpdateUserAutoResponseInfo(AdminUsername, AdminPassword,
					mailbox.Name,
					mailbox.ResponderEnabled,
					(mailbox.ResponderSubject != null ? mailbox.ResponderSubject : ""),
					(mailbox.ResponderMessage != null ? mailbox.ResponderMessage : ""));

				if (!result.Result)
					throw new Exception(result.Message);
			}
			catch (Exception ex)
			{
				throw new Exception("Could not update mailbox", ex);
			}

		}
예제 #3
0
		public override void CreateAccount(MailAccount mailbox)
		{
			try
			{
				svcUserAdmin users = new svcUserAdmin();
				PrepareProxy(users);

				GenericResult1 result = users.AddUser(AdminUsername, AdminPassword,
					mailbox.Name,
					mailbox.Password,
					GetDomainName(mailbox.Name),
					mailbox.FirstName,
					mailbox.LastName,
					false //domain admin is false
					);

				if (!result.Result)
					throw new Exception(result.Message);

				// set forwarding settings
				result = users.UpdateUserForwardingInfo(AdminUsername, AdminPassword,
					mailbox.Name, mailbox.DeleteOnForward,
					(mailbox.ForwardingAddresses != null ? String.Join(", ", mailbox.ForwardingAddresses) : ""));

				if (!result.Result)
					throw new Exception(result.Message);

				// set additional settings
				result = users.SetRequestedUserSettings(AdminUsername, AdminPassword,
					mailbox.Name,
					new string[]
                    {
                        "isenabled=" + mailbox.Enabled.ToString(),
                        "maxsize=" + mailbox.MaxMailboxSize.ToString(),
                        "passwordlocked=" + mailbox.PasswordLocked.ToString(),
                        "replytoaddress=" + (mailbox.ReplyTo != null ? mailbox.ReplyTo : ""),
                        "signature=" + (mailbox.Signature != null ? mailbox.Signature : ""),
						"spamforwardoption=none"
                    });

				if (!result.Result)
					throw new Exception(result.Message);

				// set autoresponder settings
				result = users.UpdateUserAutoResponseInfo(AdminUsername, AdminPassword,
					mailbox.Name,
					mailbox.ResponderEnabled,
					(mailbox.ResponderSubject != null ? mailbox.ResponderSubject : ""),
					(mailbox.ResponderMessage != null ? mailbox.ResponderMessage : ""));

				if (!result.Result)
					throw new Exception(result.Message);

			}
			catch (Exception ex)
			{
				throw new Exception("Could not create mailbox", ex);
			}
		}
예제 #4
0
		public void CreateAccount(MailAccount mailbox)
		{
			try
			{
				svcUserAdmin users = new svcUserAdmin();
				PrepareProxy(users);

				GenericResult result = users.AddUser(AdminUsername, AdminPassword,
					mailbox.Name,
					mailbox.Password,
					GetDomainName(mailbox.Name),
					mailbox.FirstName,
					mailbox.LastName,
					mailbox.IsDomainAdmin // domain admin is false
					);

                if (!result.Result)
                {
                    if (result.ResultCode == -21)
                        throw new Exception("Password doesn't meet complexity", new Exception(result.Message));

                    throw new Exception(result.Message);
                }

				// set forwarding settings
				result = users.UpdateUserForwardingInfo(AdminUsername, AdminPassword,
					mailbox.Name, mailbox.DeleteOnForward,
					(mailbox.ForwardingAddresses != null ? String.Join(", ", mailbox.ForwardingAddresses) : ""));

				if (!result.Result)
					throw new Exception(result.Message);

				// set additional settings
				result = users.SetRequestedUserSettings(AdminUsername, AdminPassword, mailbox.Name, mailbox.PrepareSetRequestedUserSettingsWebMethodParams());

				if (!result.Result)
					throw new Exception(result.Message);

				// set autoresponder settings
				result = users.UpdateUserAutoResponseInfo(AdminUsername, AdminPassword,
					mailbox.Name,
					mailbox.ResponderEnabled,
					(mailbox.ResponderSubject != null ? mailbox.ResponderSubject : ""),
					(mailbox.ResponderMessage != null ? mailbox.ResponderMessage : ""));

				if (!result.Result)
					throw new Exception(result.Message);

			}
			catch (Exception ex)
			{
				if (AccountExists(mailbox.Name))
				{
					DeleteAccount(mailbox.Name);
				}
				Log.WriteError(ex);
				throw new Exception("Could not create mailbox", ex);
			}
		}
예제 #5
0
		public override void UpdateAccount(MailAccount mailbox)
		{
			try
			{
                //get original account
                MailAccount account = GetAccount(mailbox.Name);  
				               
                svcUserAdmin users = new svcUserAdmin();
				PrepareProxy(users);

                
                
                string strPassword = mailbox.Password;
                
                //Don't change password. Get it from mail server.
                if (!mailbox.ChangePassword)
                {                
                    strPassword = account.Password;                                                            
                }

                GenericResult1 result = users.UpdateUser(AdminUsername, AdminPassword,
                                                             mailbox.Name,
                                                             strPassword,
                                                             mailbox.FirstName,
                                                             mailbox.LastName,
                                                             account.IsDomainAdmin
                        );                    

                if (!result.Result)
					throw new Exception(result.Message);

				// set forwarding settings
				result = users.UpdateUserForwardingInfo(AdminUsername, AdminPassword,
					mailbox.Name, mailbox.DeleteOnForward,
					(mailbox.ForwardingAddresses != null ? String.Join(", ", mailbox.ForwardingAddresses) : ""));

				if (!result.Result)
					throw new Exception(result.Message);

				// set additional settings
				result = users.SetRequestedUserSettings(AdminUsername, AdminPassword,
					mailbox.Name,
					new string[]
                    {
                        "isenabled=" + mailbox.Enabled.ToString(),
                        "maxsize=" + mailbox.MaxMailboxSize.ToString(),
                        "passwordlocked=" + mailbox.PasswordLocked.ToString(),
                        "replytoaddress=" + (mailbox.ReplyTo != null ? mailbox.ReplyTo : ""),
                        "signature=" + (mailbox.Signature != null ? mailbox.Signature : ""),
						"spamforwardoption=none"
                    });

				if (!result.Result)
					throw new Exception(result.Message);

				// set autoresponder settings
				result = users.UpdateUserAutoResponseInfo(AdminUsername, AdminPassword,
					mailbox.Name,
					mailbox.ResponderEnabled,
					(mailbox.ResponderSubject != null ? mailbox.ResponderSubject : ""),
					(mailbox.ResponderMessage != null ? mailbox.ResponderMessage : ""));

				if (!result.Result)
					throw new Exception(result.Message);
			}
			catch (Exception ex)
			{
				throw new Exception("Could not update mailbox", ex);
			}
		}