internal static void SetPassword(UserPasswordParms parms) { if (parms.UserName == null) { throw new InvalidOperationException("Must specify a user"); } foreach (var un in parms.UserName) { var user = m_client.GetUsers(o => o.UserName == un).CollectionItem.FirstOrDefault(); if (user == null) { throw new KeyNotFoundException($"User {un} not found"); } user.Password = parms.Password; m_client.UpdateUser(user.UserId.Value, user); break; } }
internal static void SetPassword(UserPasswordParms parms) { if (parms.UserName == null) { throw new InvalidOperationException("Must specify a user"); } foreach (var un in parms.UserName) { var user = m_client.GetUsers(o => o.UserName == un).CollectionItem.FirstOrDefault() as SecurityUserInfo; if (user == null) { throw new KeyNotFoundException($"User {un} not found"); } if (String.IsNullOrEmpty(parms.Password)) { var passwd = DisplayUtil.PasswordPrompt($"NEW Password for {user.Entity.UserName}:"); if (String.IsNullOrEmpty(passwd)) { Console.WriteLine("Aborted"); continue; } else if (passwd != DisplayUtil.PasswordPrompt($"CONFIRM Password for {user.Entity.UserName}:")) { Console.WriteLine("Passwords do not match!"); continue; } user.Entity.Password = passwd; } else { user.Entity.Password = parms.Password; } user.PasswordOnly = true; m_client.UpdateUser(user.Entity.Key.Value, user); break; } }