public List <RWListItem> FillUtenti() { SecurityDS ds = new SecurityDS(); using (SecurityBusiness bSecurity = new SecurityBusiness()) { bSecurity.FillUsers(ds); } List <RWListItem> utenti = (from tp in ds.USR_USER.OrderBy(x => x.FULLNAMEUSER) select new RWListItem(tp.FULLNAMEUSER, tp.UIDUSER)).ToList(); utenti = utenti.Distinct(new RWListItemComparer()).ToList(); utenti.Insert(0, new RWListItem(string.Empty, string.Empty)); return(utenti); }
public string VerifyUser(string userID, string password, string ipAddress) { SecurityDS ds = new SecurityDS(); using (SecurityBusiness bSecurity = new SecurityBusiness()) { bSecurity.FillUsers(ds); SecurityDS.USR_USERRow user = ds.USR_USER.Where(x => x.UIDUSER == userID).FirstOrDefault(); if (user == null) { return(null); } if (user.PWDUSER != password) { return(null); } using (RandomNumberGenerator rng = new RNGCryptoServiceProvider()) { StringBuilder tokenBuilder = new StringBuilder(TokenLength); Random randomizer = new Random(); for (int i = 0; i < TokenLength; i++) { int randomNumber = randomizer.Next(MinRandomPasswordValue, MaxRandomPasswordValue); char ch = Convert.ToChar(randomNumber); tokenBuilder.Append(ch); } string token = tokenBuilder.ToString(); bSecurity.SaveToken(userID, token, TokenValidityInMinutes, ipAddress); return(token); } } }