I am trying to write a small script to install all user images on their AD image, I jumped a bit in ILSpy and found out what to install using the TFS Server API, however the code should be bit because I use the client API instead.
The code that I have below can successfully iterate over all users in tfs, view them in AD, capture a thumbnail, set the property on the TFS identifier. But for my life, I cannot get an extended property for me to save it back to TFS.
The code is no exception, but the property is not set to the value that I set for it when I launch the application.
Does anyone know a way to save advanced properties through the api client?
Microsoft.TeamFoundation.Client.TeamFoundationServer teamFoundationServer = new Microsoft.TeamFoundation.Client.TeamFoundationServer("{URL TO TFS}");
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.CandidateImage.Data", thumbNail);
identity.SetProperty("Microsoft.TeamFoundation.Identity.CandidateImage.UploadDate", DateTime.UtcNow);
service2.UpdateExtendedProperties(identity);
}