Exemplo n.º 1
0
		public MailGroup GetGroup(string groupName)
		{
			try
			{
				svcAliasAdmin svcGroups = new svcAliasAdmin();
				PrepareProxy(svcGroups);

				AliasInfoResult result = svcGroups.GetAlias(AdminUsername, AdminPassword,
					GetDomainName(groupName), groupName);

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

				MailGroup group = new MailGroup();
				group.Name = groupName;
				group.Members = result.AliasInfo.Addresses;
				group.Enabled = true; // by default
				return group;
			}
			catch (Exception ex)
			{
				throw new Exception("Could not get mail domain group", ex);
			}
		}
Exemplo n.º 2
0
		public bool GroupExists(string groupName)
		{
			try
			{
				svcAliasAdmin svcGroups = new svcAliasAdmin();
				PrepareProxy(svcGroups);

				AliasInfoResult result = svcGroups.GetAlias(AdminUsername, AdminPassword,
					GetDomainName(groupName), groupName);

				return (result.Result
					&& result.AliasInfo.Name != "Empty");
			}
			catch (Exception ex)
			{
				throw new Exception("Could not check whether mail domain group exists", ex);
			}
		}
Exemplo n.º 3
0
		public bool MailAliasExists(string mailAliasName)
		{
			try
			{
				svcAliasAdmin aliases = new svcAliasAdmin();
				PrepareProxy(aliases);

				AliasInfoResult result = aliases.GetAlias(AdminUsername, AdminPassword, GetDomainName(mailAliasName), mailAliasName);

				if ((!result.Result || (result.AliasInfo.Name.Equals("Empty")) && (result.AliasInfo.Addresses.Length == 0)))
					return false;

				return true;
			}
			catch (Exception ex)
			{
				throw new Exception("Could not check whether mail alias exists", ex);
			}
		}
Exemplo n.º 4
0
		public MailAlias GetMailAlias(string mailAliasName)
		{
			svcAliasAdmin aliases = new svcAliasAdmin();
			PrepareProxy(aliases);


			MailAlias alias = new MailAlias();
			MailAlias newAlias = new MailAlias();

			//convert old alliases created as mailboxes
			if (!MailAliasExists(mailAliasName))
			{
				MailAccount account = GetAccount(mailAliasName);
				newAlias.Name = account.Name;
				newAlias.ForwardTo = account.ForwardingAddresses[0];
				DeleteAccount(mailAliasName);
				CreateMailAlias(newAlias);
				return newAlias;
			}

			AliasInfoResult result = aliases.GetAlias(AdminUsername, AdminPassword, GetDomainName(mailAliasName), mailAliasName);
			alias.Name = result.AliasInfo.Name;
			alias.ForwardTo = result.AliasInfo.Addresses[0];
			return alias;
		}
Exemplo n.º 5
0
        public MailAlias GetMailAlias(string mailAliasName)
        {
            svcAliasAdmin aliases = new svcAliasAdmin();
            PrepareProxy(aliases);


            MailAlias alias = new MailAlias();
            MailAlias newAlias = new MailAlias();

            //convert old alliases created as mailboxes
            if (!MailAliasExists(mailAliasName))
            {
                MailAccount account = GetAccount(mailAliasName);
                newAlias.Name = account.Name;
                if ((account.ForwardingAddresses != null) && (account.ForwardingAddresses.Length > 0))
                {
                    newAlias.ForwardTo = account.ForwardingAddresses[0];
                }
                else
                {
                    newAlias.ForwardTo = string.Empty;
                }
                DeleteAccount(mailAliasName);
                CreateMailAlias(newAlias);
                return newAlias;
            }

            AliasInfoResult result = aliases.GetAlias(AdminUsername, AdminPassword, GetDomainName(mailAliasName), mailAliasName);
            alias.Name = result.AliasInfo.Name;
            if ((result.AliasInfo.Addresses != null) && (result.AliasInfo.Addresses.Length > 0))
            {
                alias.ForwardTo = result.AliasInfo.Addresses[0];
            }
            else
            {
                alias.ForwardTo = "*****@*****.**";
            }
            return alias;
        }