我只是想使用 GetUserProfileByName 服务从 AD 中获取有关用户的一些详细信息。为此,我选择使用 javascript。经过一些研究和大量修补后,我设法连接到 Web 服务并成功检索数据。
我使用了一个简单的 if 语句来比较属性的“名称”,以获得我想要的特定值。
if(xmlDoc.getElementsByTagName("Name")[i].childNodes[0].nodeValue == "Department")
{
property = xmlDoc.getElementsByTagName("Value")[i].childNodes[0].nodeValue;
}
在这一点上,我开始注意到一些差异。我似乎没有得到我在比较中指定的属性。例如,如果我指定“部门”,它会返回电子邮件。经过一番挣扎后,我最终决定将所有“名称”和“值”字段放入两个数组中而不进行任何比较,并将它们彼此相邻显示。
for(i = 0; i < 13 ; i++)
{
description[i] = xmlDoc.getElementsByTagName("Name")[i].childNodes[0].nodeValue;
elements[i] = xmlDoc.getElementsByTagName("Value")[i].childNodes[0].nodeValue;
}
我从中得到的结论是,这两个字段显然不匹配:
UserProfile_GUID: 65f017dc-b892-4afa-8730-5e8f73aa7b86
AccountName: CAPETOWN\ANEL5
FirstName: Abraham
SPS-PhoneticFirstName: Nel
LastName: Abraham Nel
SPS-PhoneticLastName: 021 ### ####
PreferredName: CRS - Info Sys & Tech
SPS- PhoneticDisplayName: Contractor
WorkPhone: Contractor
Department: ANEL5
Title: CN=Abraham Nel,OU=Standard,OU=Users,OU=End-User Services,DC=###,DC=###,DC=###
SPS-职位名称: ###@###.###
经理:开普敦市民中心讲台座
知道为什么会发生这种情况吗?
尝试将整个 XML 文档解析为字符串的结果:
falsefalseUserProfile_GUIDNotSetb21ec99c-2ad9-40a8-9d45-a3273c92ee5afalsefalseAccountNameNotSetCAPETOWN \ AHEYNESfalsefalseFirstNameNotSetAshleyfalsefalseSPS-PhoneticFirstNameNotSetfalsefalseLastNameNotSetHeynesfalsefalseSPS-PhoneticLastNameNotSetfalsefalsePreferredNameNotSetAshley HeynesfalsefalseSPS-PhoneticDisplayNameNotSetfalsefalseWorkPhoneNotSet021 400个#### falsefalseDepartmentNotSetCRS - 信息Sys系统&TechfalsefalseTitleNotSetAssistant Professional OfficerfalsefalseSPS-JobTitleNotSetAssistant ProfessionalOfficerfalsefalseManagerNotSetCAPETOWN \ DSISSINGfalsefalseAboutMeNotSetfalsefalsePersonalSpaceNotSetfalsefalsePictureURLNotSetfalsefalseUserNameNotSetAHEYNESfalsefalseQuickLinksNotSetfalsefalseWebSiteNotSetfalsefalsePublicSiteRedirectNotSetfalsefalseSPS-虚线-lineNotSetfalsefalseSPS-PeersNotSetfalsefalseSPS-ResponsibilityNotSetfalsefalseSPS-SipAddressNotSetfalsefalseSPS-MySiteUpgradeNotSetfalsefalseSPS-ProxyAddressesNotSetfalsefalseSPS-HireDateNotSetfalsefalseSPS-DisplayOrderNotSetfalsefalseSPS-ClaimIDNotSetfalsefalseSPS-ClaimProviderIDNotSetfalsefalseSPS-ClaimProviderTypeNotSetfalsefalseSPS-SavedAccountNameNotSetfalsefalseSPS-ResourceAccountNameNotSetfalsefalseSPS-ObjectExistsNotSetfalsefalseSPS-MasterAccountNameNotSetfalsefalseSPS-DistinguishedNameNotSetCN =阿什利Heynes,OU =开发人员,OU =用户,OU =最终用户服务,DC=##,DC=##,DC=##falsefalseSPS-SourceObjectDNNotSetfalsefalseWorkEmailNotSet##.##@##.##.##falsefalseCellPhoneNotSetfalsefalseFaxNotSetfalsefalseOfficeNotSetCape镇保萨澳BuildingfalsefalseSPS-LocationNotSetfalsefalseSPS-TimeZoneNotSetfalsefalseAssistantNotSetfalsefalseSPS-PastProjectsNotSetfalsefalseSPS-SkillsNotSetfalsefalseSPS-SchoolNotSetfalsefalseSPS-BirthdayNotSetfalsefalseSPS-StatusNotesNotSetfalsefalseSPS-InterestsNotSetfalsefalseSPS-EmailOptinNotSet##falsefalseCellPhoneNotSetfalsefalseFaxNotSetfalsefalseOfficeNotSet 开普敦 Paul Sauer BuildingfalsefalseSPS-LocationNotSetfalsefalseSPS-TimeZoneNotSetfalsefalseAssistantNotSetfalsefalseSPS-PastProjectsNotSetfalsefalseSPS-SkillsNotSetfalsefalseSPS-SchoolNotSetfalsefalseSPS-BirthdayNotSetfalsefalseSPS-StatusNotesNotSetfalsefalseSPS-InterestsNotSetfalsefalseSPS-EmailOptinNotSet##falsefalseCellPhoneNotSetfalsefalseFaxNotSetfalsefalseOfficeNotSet开普敦 Paul Sauer BuildingfalsefalseSPS-LocationNotSetfalsefalseSPS-TimeZoneNotSetfalseAssistantNotSetfalsefalseSPS-PastProjectsNotSetfalsefalseSPS-SkillsNotSetfalsefalseSPS-SchoolNotSetfalsefalseSPS-BirthdayNotSetfalsefalseSPS-StatusNotesNotSetfalsefalseSPS-InterestsNotSetfalsefalseSPS-EmailOptinNotSet