Skip to content

Commit b643971

Browse files
MrHinshsl-io
andauthored
Refactor user group name handling in TfsUserMappingTool (#2906)
Replaced hardcoded "Project Collection Valid Users" string in `TfsUserMappingTool.cs` with a configurable property `Options.ProjectCollectionValidUsersGroupName`. Added this property to `TfsUserMappingToolOptions.cs` to allow customization of the group name, with a default value of "Project Collection Valid Users". Co-authored-by: sl-io <[email protected]>
2 parents b6c3021 + 39aaca6 commit b643971

File tree

5 files changed

+21
-2
lines changed

5 files changed

+21
-2
lines changed

docs/data/classes/reference.tools.tfsusermappingtool.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ configurationSamples:
7171
"Microsoft.VSTS.Common.ClosedBy"
7272
],
7373
"UserMappingFile": "C:\\temp\\userExport.json",
74-
"MatchUsersByEmail": false
74+
"MatchUsersByEmail": false,
75+
"ProjectCollectionValidUsersGroupName": "Project Collection Valid Users"
7576
}
7677
sampleFor: MigrationTools.Tools.TfsUserMappingToolOptions
7778
description: The TfsUserMappingTool is used to map users from the source to the target system. Run it with the ExportUsersForMappingContext to create a mapping file then with WorkItemMigrationContext to use the mapping file to update the users in the target system as you migrate the work items.
@@ -90,6 +91,10 @@ options:
9091
type: Boolean
9192
description: By default, users in source are mapped to target users by their display name. If this is set to true, then the users will be mapped by their email address first. If no match is found, then the display name will be used.
9293
defaultValue: missing XML code comments
94+
- parameterName: ProjectCollectionValidUsersGroupName
95+
type: String
96+
description: This is the regionalized "Project Collection Valid Users" group name. Default is "Project Collection Valid Users".
97+
defaultValue: missing XML code comments
9398
- parameterName: UserMappingFile
9499
type: String
95100
description: This is the file that will be used to export or import the user mappings. Use the ExportUsersForMapping processor to create the file.

docs/static/schema/configuration.schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,10 @@
14441444
"description": "By default, users in source are mapped to target users by their display name. If this is set to true, then the users will be mapped by their email address first. If no match is found, then the display name will be used.",
14451445
"type": "boolean"
14461446
},
1447+
"projectCollectionValidUsersGroupName": {
1448+
"description": "This is the regionalized \"Project Collection Valid Users\" group name. Default is \"Project Collection Valid Users\".",
1449+
"type": "string"
1450+
},
14471451
"userMappingFile": {
14481452
"description": "This is the file that will be used to export or import the user mappings. Use the ExportUsersForMapping processor to create the file.",
14491453
"type": "string"

docs/static/schema/schema.tools.tfsusermappingtool.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
"description": "By default, users in source are mapped to target users by their display name. If this is set to true, then the users will be mapped by their email address first. If no match is found, then the display name will be used.",
1818
"type": "boolean"
1919
},
20+
"projectCollectionValidUsersGroupName": {
21+
"description": "This is the regionalized \"Project Collection Valid Users\" group name. Default is \"Project Collection Valid Users\".",
22+
"type": "string"
23+
},
2024
"userMappingFile": {
2125
"description": "This is the file that will be used to export or import the user mappings. Use the ExportUsersForMapping processor to create the file.",
2226
"type": "string"

src/MigrationTools.Clients.TfsObjectModel/Tools/TfsUserMappingTool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private Dictionary<string, string> GetMappingFileData()
121121

122122
private List<IdentityItemData> GetUsersListFromServer(IGroupSecurityService gss)
123123
{
124-
Identity allIdentities = gss.ReadIdentity(SearchFactor.AccountName, "Project Collection Valid Users", QueryMembership.Expanded);
124+
Identity allIdentities = gss.ReadIdentity(SearchFactor.AccountName, Options.ProjectCollectionValidUsersGroupName, QueryMembership.Expanded);
125125
Log.LogInformation("TfsUserMappingTool::GetUsersListFromServer Found {count} identities (users and groups) in server.", allIdentities.Members.Length);
126126

127127
List<IdentityItemData> foundUsers = new List<IdentityItemData>();

src/MigrationTools.Clients.TfsObjectModel/Tools/TfsUserMappingToolOptions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ public class TfsUserMappingToolOptions : ToolOptions, ITfsUserMappingToolOptions
3131
/// </summary>
3232
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
3333
public bool SkipValidateAllUsersExistOrAreMapped { get; set; } = false;
34+
35+
/// <summary>
36+
/// This is the regionalized "Project Collection Valid Users" group name. Default is "Project Collection Valid Users".
37+
/// </summary>
38+
public string ProjectCollectionValidUsersGroupName { get; set; } = "Project Collection Valid Users";
39+
3440
}
3541

3642
public interface ITfsUserMappingToolOptions

0 commit comments

Comments
 (0)