Last active
June 12, 2025 22:03
-
-
Save bzbetty/4077563 to your computer and use it in GitHub Desktop.
[Archived]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Microsoft.TeamFoundation.Client.TeamFoundationServer teamFoundationServer = new Microsoft.TeamFoundation.Client.TeamFoundationServer("http://UrlToTFS"); | |
FilteredIdentityService service = teamFoundationServer.GetService<FilteredIdentityService>(); ; | |
IIdentityManagementService2 service2 = teamFoundationServer.GetService<IIdentityManagementService2>(); | |
foreach (var identity in service.SearchForUsers("")) | |
{ | |
var user = UserPrincipal.FindByIdentity(new PrincipalContext(ContextType.Domain), identity.UniqueName); | |
if (user == null) continue; | |
var de = new System.DirectoryServices.DirectoryEntry("LDAP://" + user.DistinguishedName); | |
var thumbNail = de.Properties["thumbnailPhoto"].Value as byte[]; | |
identity.SetProperty("Microsoft.TeamFoundation.Identity.Image.Data", thumbNail); | |
identity.SetProperty("Microsoft.TeamFoundation.Identity.Image.Type", "image/bmp"); | |
identity.SetProperty("Microsoft.TeamFoundation.Identity.Image.Id", Guid.NewGuid().ToByteArray()); | |
identity.SetProperty("Microsoft.TeamFoundation.Identity.CandidateImage.Data", null); | |
identity.SetProperty("Microsoft.TeamFoundation.Identity.CandidateImage.UploadDate", null); | |
service2.UpdateExtendedProperties(identity); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment