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 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); }