private static void ExportGroups(VaultUserAccountsOptions options) { using (KnowledgeMaster master = new KnowledgeMaster(options.Server, options.UserName, options.Password, options.AuthenticationType)) { List <GroupInfo> groupInfos = new List <GroupInfo>(); foreach (Group group in master.GetAllGroups()) { if (true == group.IsSys) { continue; } Console.WriteLine("Processing group '{0}'", group.Name); GroupInfo groupInfo = new GroupInfo(group); groupInfo.Groups.AddRange(master.GetGroupNamesForGroup(group.Id)); groupInfo.Roles.AddRange(master.GetRoleNamesForGroup(group.Id)); groupInfo.Vaults.AddRange(master.GetVaultNamesForGroup(group.Id)); groupInfos.Add(groupInfo); } WriteGroupsToFile(options.FileName, groupInfos); } }
private static void ExportUsers(VaultUserAccountsOptions options) { using (KnowledgeMaster master = new KnowledgeMaster(options.Server, options.UserName, options.Password, options.AuthenticationType)) { List <UserInfo> userInfos = new List <UserInfo>(); foreach (User user in master.GetAllUsers()) { if (true == user.IsSys) { continue; } Console.WriteLine("Processing user '{0}'", user.Name); UserInfo userInfo = new UserInfo(user); userInfo.Groups.AddRange(master.GetGroupNamesForUser(user.Id)); userInfo.Roles.AddRange(master.GetRoleNamesForUser(user.Id)); userInfo.Vaults.AddRange(master.GetVaultNamesForUser(user.Id)); userInfos.Add(userInfo); } WriteFile(options.FileName, userInfos); } }
private static void ImportUsers(VaultUserAccountsOptions options) { using (KnowledgeMaster master = new KnowledgeMaster(options.Server, options.UserName, options.Password, options.AuthenticationType)) { List <UserInfo> userInfos = ReadFile(options.FileName); foreach (UserInfo userInfo in userInfos) { try { Console.WriteLine("Processing user '{0}'", userInfo.LoginName); master.UpdateUser(userInfo); } catch (Exception ex) { Console.WriteLine("ERROR: {0}", VDF.Library.ExceptionParser.GetMessage(ex)); #if DEBUG Console.WriteLine("StackTrace: {0}", ex.StackTrace); #endif } } } }