GetUserProfileByName properties incompatible

I'm just trying to use the GetUserProfileByName service to get some user information from AD. For this, I decided to use javascript. After a small amount of research and a significant amount of mastering, I managed to connect to the web service and successfully receive the data.

I used a simple if statement to compare the "name" of the property to get the value I want.

if(xmlDoc.getElementsByTagName("Name")[i].childNodes[0].nodeValue == "Department") { property = xmlDoc.getElementsByTagName("Value")[i].childNodes[0].nodeValue; } 

At this point, I began to notice some inconsistencies. It seems I did not get the property that I am specifying in the comparison. For example, if I specify "Department", it will return an email. After many attempts, I finally decided to simply drop all the "Name" and "Value" fields into two arrays without any comparison and show them next to each other.

 for(i = 0; i < 13 ; i++) { description[i] = xmlDoc.getElementsByTagName("Name")[i].childNodes[0].nodeValue; elements[i] = xmlDoc.getElementsByTagName("Value")[i].childNodes[0].nodeValue; } 

The conclusion I got from this was that the two fields clearly did not match each other:

UserProfile_GUID: 65f017dc-b892-4afa-8730-5e8f73aa7b86
Account Name: CAPETOWN \ ANEL5
FirstName: Abraham
SPS-PhoneticFirstName: Nel
LastName: Abraham Nel
SPS-PhoneticLastName: 021 ### ####
Preferred Name: CRS - Info Sys and Tech
SPS-PhoneticDisplayName: Contractor
WorkPhone: Contractor
Department: ANEL5
Title: CN = Abraham Nel, OU = Standard, OU = Users, OU = End User Services, DC = ###, DC = ###, DC = ###
SPS-JobTitle: ###@###.###
Manager: Cape Town Civic Center Podium Block

Any idea why this is happening?

The result of trying to parse the entire XML document into a string:

falsefalseUserProfile_GUIDNotSetb21ec99c-2ad9-40a8-9d45-a3273c92ee5afalsefalseAccountNameNotSetCAPETOWN \ AHEYNESfalsefalseFirstNameNotSetAshleyfalsefalseSPS-PhoneticFirstNameNotSetfalsefalseLastNameNotSetHeynesfalsefalseSPS-PhoneticLastNameNotSetfalsefalsePreferredNameNotSetAshley HeynesfalsefalseSPS-PhoneticDisplayNameNotSetfalsefalseWorkPhoneNotSet021 400 #### falsefalseDepartmentNotSetCRS - Info Sys and TechfalsefalseTitleNotSetAssistant Professional OfficerfalsefalseSPS-JobTitleNotSetAssistant Professional OfficerfalsefalseManagerNotSetCAPETOWN \ DSISSINGfalsefalseAboutMeNotSetfalsefalsePersonalSpaceNotSetfalsefalsePictureURLNotSetfalsefalseUserNameNotSetAHEYNESfalsefalseQuickLinksNotSetfalsefalseWebSiteNotSetfalsefalsePublicSiteRedirectNotSetfalsefalseSPS-dot-lineNotSetfalsefalseSPS-PeersNotSetfalsefalseSPS-ResponsibilityNotSetfalsefalseSPS-SipAddressNotSetfalsefalseSPS -MySiteUpgradeNotSetfalsefalseSPS- ProxyAddressesNotSetfalsefalseS PS-HireDateNotSetfalsefalseSPS-DisplayOrderNot SetfalsefalseSPS-ClaimIDNotSetfalsefalseSPS-ClaimProviderIDNotSetfalsefalseSPS-ClaimProviderTypeNotSetfalsefalseSPS-SavedAccountNameNotSetfalsefalseSPS-ResourceAccountNameNotSetfalsefalseSPS-ObjectExistsNotSetfalsefalseSPS-MasterAccountNameNotSetfalsefalseSPS-DistinguishedNameNotSetCN = Ashley Heynes, OU = Developers, OU = Users, OU = end-user services, DC = ##, DC = ##, DC = ## falsefalseSPS-SourceObjectDNNotSetfalsefalseWorkEmailNotSet##.##@##.##.##falsefalseCellPhoneNotSetfalsefalseFaxNotSetfalsefalseOfficeNotSetCape City Sauer BuildingfalsefalseSPS-LocationNotSetfalsefalseSPS-TimeZoneNotSetfalsefalseAssistantNotSetfalsefalseSPS-PastProjectsNotSetfalsefalseSPS-SkillsNotSetfalsefalseSPS-SchoolNotSetfalsefalseSPS-BirthdayNotSetfalsefalseSPS-StatusNotesNotSetfalsefalseSPS-InterestsNotSetfalsefalseSPS-EmailOptinNotSet

+4
source share
1 answer

Searched around, and it seems that the XML structure does not lend itself to the logic that you use. XML looks like this:

 PropertyData* Name Values ValueData Value 

I am not sure about the power of each of them, but I believe that it is safer to xmlDoc.getElementsByTagName('PropertyData') over xmlDoc.getElementsByTagName('PropertyData') , and then find the Name and (possibly several) Value elements inside this block.

 var properties = xmlDoc.getElementsByTagName("PropertyData"); for (var i = 0, item; item = properties[i]; ++i) { // search for Name and Value inside here } 

Update

Most likely, this is caused by several values ​​for FirstName : Abraham , Nel and Abraham Nel .

+1
source

Source: https://habr.com/ru/post/1440284/


All Articles