private void CopyRepositories(BonoboGitServerContext context) { var repos = context.Query <OldRepo>().FromSql("SELECT * FROM oRepo"); foreach (var repo in repos) { _db.ExecuteSqlCommand("INSERT INTO Repository VALUES ({0}, {1}, {2}, {3}, {4}, {5}, {6})", Guid.NewGuid(), repo.Name, repo.Description, repo.Anonymous, repo.AuditPushUser, repo.Group, repo.Logo); } }
private void CopyTeams(BonoboGitServerContext context) { var teams = context.Query <NameDesc>().FromSql("Select * from oTeam"); foreach (var team in teams) { _db.ExecuteSqlCommand("INSERT INTO Team VALUES ({0}, {1}, {2})", Guid.NewGuid(), team.Name, team.Description); } }
private void CopyRoles(BonoboGitServerContext context) { var roles = context.Query <NameDesc>().FromSql("Select * from oRole"); foreach (var role in roles) { _db.ExecuteSqlCommand("INSERT INTO Role VALUES ({0}, {1}, {2})", // Administrator is a default role and should have the same Guid on all systems to make debugging easier role.Name.Equals("Administrator") ? new Guid("a3139d2b-5a59-427f-bb2d-af251dce00e4") : Guid.NewGuid(), role.Name, role.Description); } }
private void CopyUsers(BonoboGitServerContext context) { var users = context.Query <OldUser>().FromSql("Select * from oUser;"); foreach (var entry in users) { Guid guid = Guid.NewGuid(); if (AuthProvider is WindowsAuthenticationProvider) { var user = ADHelper.GetUserPrincipal(entry.Username); // if the user no longer exists // it means he cannot login anymore so it is safe to assign // any new guid to him if (user != null) { guid = user.Guid.Value; if (string.IsNullOrEmpty(entry.Email) || entry.Email.Equals("None", StringComparison.OrdinalIgnoreCase)) { entry.Email = user.EmailAddress; } if (string.IsNullOrEmpty(entry.Surname) || entry.Surname.Equals("None", StringComparison.OrdinalIgnoreCase)) { entry.Surname = user.Surname; } if (string.IsNullOrEmpty(entry.Name) || entry.Name.Equals(entry.Username, StringComparison.OrdinalIgnoreCase)) { entry.Name = user.GivenName; } } } else { // just make sure the admin user has the same guid everywhere. This should make it // easier to identify this user if (entry.Name == "admin") { guid = new Guid("3eb9995e-99e3-425a-b978-1409bdd61fb6"); } } // Existing users will have had passwords which were salted with their username, so we need to replicate that into the Salt column var salt = entry.Username; _db.ExecuteSqlCommand("INSERT INTO [User] VALUES ({0}, {1}, {2}, {3}, {4}, {5}, {6})", guid.ToString(), entry.Name, entry.Surname, entry.Username, entry.Password, salt, entry.Email); } }