public void LoadSettings() { try { _xm.Login(); string raw = _xm.GetConfigFile(AdminPanelConstants.serverTab); _xm.Logout(); string line = string.Empty; using (StringReader sr = new StringReader(raw)) { while ((line = sr.ReadLine()) != null) { line = line.Trim(); if (line == ".") { break; } XMSettingsRow row = XMSettingsRow.Parse(line); if (row != null) { _rows.Add(row); } } } } catch (Exception error) { Log.WriteException(error); } }
public static List <string> GetUsersAliases(string dName, string uName) { List <string> userAliases = new List <string>(); try { XMLayer xm = new XMLayer(); xm = XMServer.CreateXMLayer(); xm.Login(); string raw = ""; string line; raw = xm.ListAliases(dName, "*", uName); using (StringReader sr = new StringReader(raw)) { while ((line = sr.ReadLine()) != null) { line = line.Trim(); if (line == ".") { break; } userAliases.Add(extractUsersAliasName(line)); } } xm.Logout(); } catch (Exception error) { Log.WriteException(error); } return((userAliases.Count == 0) ? null : userAliases); }
public static bool UserExist(string dName, string uName) { bool res = false; string line = string.Empty; string users = string.Empty; Regex re = new Regex("\\s+"); try { XMLayer xmLayer = new XMLayer(); xmLayer = XMServer.CreateXMLayer(); xmLayer.Login(); users = xmLayer.ListUsers(dName, uName); xmLayer.Logout(); if (users.Contains(dName) && users.Contains(uName)) { res = true; } } catch (Exception error) { Log.WriteException(error); } return(res); }
public static bool GetMailBoxInstruct(string dName, string uName) { try { XMLayer xm = new XMLayer(); xm = XMServer.CreateXMLayer(); string raw = ""; string line; xm.Login(); raw = xm.GetMailProcTab(dName, uName); xm.Logout(); using (StringReader sr = new StringReader(raw)) { while ((line = sr.ReadLine()) != null) { if (line.Contains("mailbox")) { return(true); } } } } catch (Exception error) { Log.WriteException(error); } return(false); }
public static void SaveUserVariables(string domainName, string userName, string MaxMailboxSize, bool StoreMailLocaly) { try { List <string> varNames = new List <string>(); List <string> varValues = new List <string>(); varNames.Add("MaxMBSize"); varValues.Add(MaxMailboxSize.Trim()); varNames.Add("StoreMailLocaly"); if (StoreMailLocaly) { varValues.Add("1"); } else { varValues.Add("0"); } XMLayer xm = new XMLayer(); xm = XMServer.CreateXMLayer(); xm.Login(); xm.SetUserVariable(domainName, userName, varNames.ToArray(), varValues.ToArray()); xm.Logout(); } catch (Exception error) { Log.WriteException(error); throw; } }
public static void DelMailBoxInstruct(string dName, string uName) { try { XMLayer xm = new XMLayer(); xm = XMServer.CreateXMLayer(); string raw = string.Empty; string line = string.Empty; string res_lines = string.Empty; xm.Login(); raw = xm.GetMailProcTab(dName, uName); StringWriter sw = new StringWriter(); using (StringReader sr = new StringReader(raw)) { while ((line = sr.ReadLine()) != null) { if (!line.Contains("mailbox")) { sw.WriteLine(line); } } } xm.SetMailProcTab(dName, uName, sw.ToString()); xm.Logout(); } catch (Exception error) { Log.WriteException(error); } }
public static void AddUser(string domain, string login, string password, bool MailingList, double MaxMailboxSize, bool StoreMailLocaly) { try { List <string> varNames = new List <string>(); List <string> varValues = new List <string>(); varNames.Add("MaxMBSize"); varValues.Add(MaxMailboxSize.ToString().Trim()); varNames.Add("StoreMailLocaly"); if (StoreMailLocaly) { varValues.Add("1"); } else { varValues.Add("0"); } XMLayer xm = new XMLayer(); xm = XMServer.CreateXMLayer(); xm.Login(); xm.AddUser(domain, login, password, (MailingList == true) ? "M" : "U"); xm.SetUserVariable(domain, login, varNames.ToArray(), varValues.ToArray()); xm.Logout(); } catch (Exception error) { Log.WriteException(error); throw; } }
public static XMDomainCollection GetCustomDomainins() { XMDomainCollection xmDomains = new XMDomainCollection(); XMLayer xmLayer = new XMLayer(); try { xmLayer = XMServer.CreateXMLayer(); xmLayer.Login(); string domains = xmLayer.ListCustomDomains(); using (StringReader sr = new StringReader(domains)) { string line = string.Empty; while ((line = sr.ReadLine()) != null) { line = line.Trim(); if (line == ".") { break; } string domainName = line.Trim(new char[] { '"' }); xmDomains.Add(new XMDomain(domainName, domainName, AdminPanelConstants.UserType.xm)); } } xmLayer.Logout(); } catch (Exception error) { Log.WriteException(error); throw; } return(xmDomains); }
public static List <ExternalLinkObject> GetExternalLink(string dName, string uName) { List <ExternalLinkObject> ExternalLink = new List <ExternalLinkObject>(); XMLayer xm = new XMLayer(); try { xm = XMServer.CreateXMLayer(); xm.Login(); string raw = ""; string line; raw = xm.ListPop3ExternalLink(dName, uName); xm.Logout(); using (StringReader sr = new StringReader(raw)) { while ((line = sr.ReadLine()) != null) { line = line.Trim(); if (line == ".") { break; } ExternalLinkObject elobj = new ExternalLinkObject(); elobj.server = extractExternalLink(line, "SERVER_NAME"); elobj.user = extractExternalLink(line, "USER_NAME"); ExternalLink.Add(elobj); } } } catch (Exception error) { Log.WriteException(error); } return(ExternalLink); }
public static RedirectionsList GetRedirections(string dName, string uName)// { RedirectionsList result = new RedirectionsList(); result.forwards = new List <string>(); result.activeForwards = new List <string>(); try { XMLayer xm = new XMLayer(); xm = XMServer.CreateXMLayer(); string raw = ""; string line; xm.Login(); raw = xm.GetMailProcTab(dName, uName); xm.Logout(); using (StringReader sr = new StringReader(raw)) { string[] data; int i = 0; while ((line = sr.ReadLine()) != null) { line = line.Trim(); if (line == ".") { break; } data = extractMailProc(line); switch (data[0]) { case "redirect": for (i = 1; i < data.Length; i++) { result.forwards.Add(data[i]); } break; case "lredirect": for (i = 1; i < data.Length; i++) { result.activeForwards.Add(data[i]); } break; default: break; } } } } catch (Exception error) { Log.WriteException(error); } return(result); }
public static string[] GetCustomDomainTab(string customDomainName) { string[] result = new string[2]; XMLayer xm = XMServer.CreateXMLayer(); Hashtable ht = new Hashtable(); try { xm.Login(); string raw = xm.GetCustomDomainFile(customDomainName); string line; result[0] = ""; result[1] = ""; string[] id; using (StringReader sr = new StringReader(raw)) { while ((line = sr.ReadLine()) != null) { line = line.Trim(); if (line == ".") { break; } id = extractCustomDomainData(line); line = line.Trim(); switch (id[0]) { case "mailbox": case "redirect": case "lredirect": result[0] += line + "\r\n"; break; default: result[1] += line + "\r\n"; break; } } } } catch (Exception error) { Log.WriteException(error); throw; } finally { xm.Logout(); } return(result); }
public static string[] GetMailProcTab(string domainName, string userName) { string[] result = new string[2] { "", "" }; XMLayer xm = new XMLayer(); try { xm = XMServer.CreateXMLayer(); xm.Login(); string raw = xm.GetMailProcTab(domainName, userName); xm.Logout(); string line; result[0] = ""; result[1] = ""; string[] id; using (StringReader sr = new StringReader(raw)) { while ((line = sr.ReadLine()) != null) { line = line.Trim(); if (line == ".") { break; } id = extractMailProc(line); line = line.Trim(); switch (id[0]) { case "mailbox": case "redirect": case "lredirect": result[0] += line + "\r\n"; break; default: result[1] += line + "\r\n"; break; } } } } catch (Exception error) { Log.WriteException(error); } return(result); }
public static void DeleteExternalLink(string domainName, string userName, string extDomainName, string extUserName) { try { XMLayer xm = new XMLayer(); xm = XMServer.CreateXMLayer(); xm.Login(); xm.DeletePop3ExternalLink(domainName, userName, extDomainName.Trim(), extUserName.Trim()); xm.Logout(); } catch (Exception) { throw; } }
public static void DeleteListUser(string domainName, string userName, string address) { try { XMLayer xm = new XMLayer(); xm = XMServer.CreateXMLayer(); xm.Login(); xm.DeleteMailingListUser(domainName, userName, address.Trim()); xm.Logout(); } catch (Exception error) { Log.WriteException(error); throw; } }
public static void AddListUser(string domainName, string userName, string NewUserAddressID, MLPERMISSIONS permisson) { try { XMLayer xm = new XMLayer(); xm = XMServer.CreateXMLayer(); xm.Login(); xm.AddMailingListUser(domainName, userName, NewUserAddressID, permisson); xm.Logout(); } catch (Exception error) { Log.WriteException(error); throw; } }
public static void AddNewAlias(string domainName, string userName, string AccountAliasID) { try { XMLayer xm = new XMLayer(); xm = XMServer.CreateXMLayer(); xm.Login(); xm.AddAlias(domainName, userName, AccountAliasID); xm.Logout(); } catch (Exception error) { Log.WriteException(error); throw; } }
public static void DeleteUser(string domainName, string userName) { try { XMLayer xm = new XMLayer(); xm = XMServer.CreateXMLayer(); xm.Login(); xm.DeleteUser(domainName, userName); xm.Logout(); } catch (Exception error) { Log.WriteException(error); throw; } }
public static void DeleteAlias(string domainName, string aliasNameForDelete) { XMLayer xm = new XMLayer(); try { xm = XMServer.CreateXMLayer(); xm.Login(); xm.DeleteAlias(domainName, aliasNameForDelete); xm.Logout(); } catch (Exception error) { Log.WriteException(error); throw; } }
public static string GetAdvanced(string dName, string uName) { string content = ""; XMLayer xm = new XMLayer(); try { xm = XMServer.CreateXMLayer(); xm.Login(); string raw = ""; string line; raw = xm.GetMailProcTab(dName, uName); xm.Logout(); using (StringReader sr = new StringReader(raw)) { string[] data; while ((line = sr.ReadLine()) != null) { line = line.Trim(); if (line == ".") { break; } data = extractMailProc(line); switch (data[0]) { case "mailbox": case "redirect": case "lredirect": break; default: content += line + "\r\n"; break; } } } } catch (XMailException error) { Log.WriteException(error); } return(content); }
public static void AddExternalLink(string domainName, string userName, string ExternalPOP3Server, string ExternalUserName, string ExternalPassword, AUTHTYPE authType) { try { XMLayer xm = new XMLayer(); xm = XMServer.CreateXMLayer(); xm.Login(); xm.AddPop3ExternalLink(domainName, userName, ExternalPOP3Server, ExternalUserName, ExternalPassword, authType); xm.Logout(); } catch (Exception error) { Log.WriteException(error); throw; } }
public static List <string> GetListMembers(string dName, string uName) { List <string> userList = new List <string>(); try { XMLayer xm = new XMLayer(); xm = XMServer.CreateXMLayer(); xm.Login(); string raw = xm.ListMailingListUsers(dName, uName); xm.Logout(); string line; using (StringReader sr = new StringReader(raw)) { while ((line = sr.ReadLine()) != null) { line = line.Trim(); if (line == ".") { break; } string userAddress = extractMailingListUserInfo(line, "Address"); string userAccess = ""; string userAccessType = extractMailingListUserInfo(line, "AccessType"); if (userAccessType.ToUpper().IndexOf("R") > -1) { userAccess = "Read"; } if ((userAccessType.ToUpper().IndexOf("R") > -1) && (userAccessType.ToUpper().IndexOf("W") > -1 || userAccessType.ToUpper().IndexOf("A") > -1)) { userAccess = "Read/Post"; } userList.Add(userAddress + " (" + userAccess + ")"); } } } catch (Exception error) { Log.WriteException(error); } return(userList); }
public static void DeleteDomain(string name) { if (!string.IsNullOrEmpty(name)) { XMLayer xmLayer = new XMLayer(); try { xmLayer = XMServer.CreateXMLayer(); xmLayer.Login(); xmLayer.DeleteDomain(name); xmLayer.Logout(); } catch (XMailException ex) { Log.WriteException(ex); throw; } } }
public static void AdvancedSaveChanges(string domainName, string userName, string Advanced) { try { XMLayer xm = new XMLayer(); xm = XMServer.CreateXMLayer(); xm.Login(); string data = XMUser.GetMailProcTab(domainName, userName)[0]; data += Advanced.Trim(); data += "\r\n.\r\n"; xm.SetMailProcTab(domainName, userName, data); xm.Logout(); } catch (Exception error) { Log.WriteException(error); throw; } }
public static void AddDomain(string domain) { XMLayer xmLayer = XMServer.CreateXMLayer(); try { xmLayer.Login(); xmLayer.AddDomain(domain); } catch (Exception error) { Log.WriteException(error); throw; } finally { xmLayer.Logout(); } }
public void UpdateXMailDomain() { try { XMLayer xmLayer = XMServer.CreateXMLayer(); xmLayer.Login(); if (Int32.Parse(hidCustomDomain.Value) == 1) { // edit custom domain StringBuilder redirect = new StringBuilder("redirect"); /* * if (Request.Params[RedirectionsListDDL.UniqueID] != null) * { * string[] RedirectionsList = Request.Params[RedirectionsListDDL.UniqueID].ToString().Split(','); * for (int i = 0; i < RedirectionsList.Length; i++) * redirect.AppendFormat("\t\"{0}\"", RedirectionsList[i]); * } */ StringBuilder lredirect = new StringBuilder("lredirect"); if (Request.Params[LRedirectionsListDDL.UniqueID] != null) { string[] LRedirectionsList = Request.Params[LRedirectionsListDDL.UniqueID].ToString().Split(','); for (int i = 0; i < LRedirectionsList.Length; i++) { lredirect.AppendFormat("\t\"{0}\"", LRedirectionsList[i]); } } string data = string.Format("{0}\r\n{1}\r\n{2}\r\n.\r\n", redirect.ToString(), lredirect.ToString(), AdvancedID.Text); xmLayer.SetCustomDomainTab(textDomainName.Value.Trim(), data); } xmLayer.Logout(); } catch (Exception ex) { Log.WriteException(ex); AdminPanelUtils.SetPageErrorMessage(this.Page, ex.Message); } }
public static void SetControlAccounts(List <AdminPanelControlAccount> cAccounts) { try { XMLayer xm = XMServer.CreateXMLayer(); string param = string.Empty; foreach (AdminPanelControlAccount ca in cAccounts) { param += '\"' + ca.Name + '\"' + '\t' + '\"' + AdminPanelUtils.EncryptPassword(ca.Password) + '\"' + "\r\n"; } xm.Login(); xm.SetCtrlAccounts(param); xm.Logout(); } catch (Exception error) { Log.WriteException(error); throw new WebMail.WebMailException(error); } }
public static UserInfo GetUser(string dName, string uName) { UserInfo user = new UserInfo(); string line = string.Empty; string users = string.Empty; Regex re = new Regex("\\s+"); try { XMLayer xmLayer = new XMLayer(); xmLayer = XMServer.CreateXMLayer(); xmLayer.Login(); users = xmLayer.ListUsers(dName, uName); xmLayer.Logout(); using (StringReader sr = new StringReader(users)) { while ((line = sr.ReadLine()) != null) { line = line.Trim(); if (line == ".") { break; } string[] us = re.Split(line); user.domain = us[0].Trim(new char[] { '"' }); user.user = us[1].Trim(new char[] { '"' }); user.pass = us[2].Trim(new char[] { '"' }); user.type = us[3].Trim(new char[] { '"' }); } } } catch (Exception error) { Log.WriteException(error); } return(user); }
public static void ChangePassword(string domainName, string userName, string userPassword) { try { string res = string.Empty; if (userPassword != string.Empty) { XMLayer xmLayer = new XMLayer(); xmLayer = XMServer.CreateXMLayer(); xmLayer.Login(); res = xmLayer.ChangePassword(domainName, userName, userPassword); xmLayer.Logout(); if (res == "+00000 OK") { res = string.Empty; } } } catch (Exception error) { Log.WriteException(error); } }
public static void SetMailBoxInstruct(string dName, string uName) { try { XMLayer xm = new XMLayer(); xm = XMServer.CreateXMLayer(); string raw = ""; xm.Login(); try { raw = xm.GetMailProcTab(dName, uName); } catch (XMailAdminProxy.XMailException) { } raw = "\"mailbox\"\r\n" + raw; xm.SetMailProcTab(dName, uName, raw); xm.Logout(); } catch (Exception error) { Log.WriteException(error); } }
public static List <AdminPanelControlAccount> GetControlAccounts() { List <AdminPanelControlAccount> cAccounts = new List <AdminPanelControlAccount>(); try { XMLayer xm = XMServer.CreateXMLayer(); string raw = string.Empty; string line; xm.Login(); raw = xm.GetCtrlAccounts(); xm.Logout(); using (StringReader sr = new StringReader(raw)) { string[] data; AdminPanelControlAccount cAccount = new AdminPanelControlAccount(); while ((line = sr.ReadLine()) != null) { line = line.Trim(); if (line == ".") { break; } data = extractCtrlAccounts(line); cAccount.Name = data[0]; cAccount.Password = AdminPanelUtils.DecryptPassword(data[1]); cAccounts.Add(cAccount); } } } catch (Exception error) { Log.WriteException(error); throw new WebMail.WebMailException(error); } return(cAccounts); }