0

I'm developing an Infopath form. I'd like to only use a webservice if possible.
Of course with code I can tap right into AD. But not what I need for this project.

I'm looking around I've check out

  • /_vti_bin/usergroup.asmx
  • /_vti_bin/userprofileservice.asmx

What webservice will get me the users phone number... not the current user... but a user I've selected from a menu selection. I've been searching through:
http://msdn.microsoft.com/en-us/library/dd878586(v=office.12).aspx

When I try this:

var accountName = "LayEN";
var propertyName = "PreferredName";

var soapEnv =
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:tns='http://schemas.microsoft.com/sharepoint/soap/'> \
    <soap:Body> \
        <GetUserProfileByName xmlns='http://microsoft.com/webservices/SharePointPortalServer/UserProfileService'> \
            <AccountName>" + accountName+ "</AccountName> \
        </GetUserProfileByName> \
    </soap:Body> \
</soap:Envelope>";

$.ajax({
    url: "/_vti_bin/userprofileservice.asmx",
    type: "POST",
    dataType: "xml",
    data: soapEnv,
    complete: processResult,
    contentType: "text/xml; charset='utf-8'"    
});

function processResult(xData, status) {

    console.log (xData.responseXML);

     $(xData.responseXML).find("PropertyData > Name:contains('PreferredName')").each(function() {
        if($(this).parent().find("Values").text().length > 0)
        $("#list").append('<li>' + $(this).parent().find("Values").text() + '</li>');
    });


}

I get this error:

soap:ClientA user with the account name Windows2000\LayEN could not be found. ---> An error was encountered while retrieving the user profile.UserCannotBeFoundAn error was encountered while retrieving the user profile.

1

GetUserProfileByName in UserProfileService.asmx should allow you to get what you want. You simply have to provide it an AccountName.

Also, Clayton has an expansive walkthrough of using the GetUserProfileByName operation in a variety of ways that may be beneficial.

  • Other users don't seem to work. We just enable UserProfileservice.asmx on the server. Is it have the same info as ActiveDirectory? – Ben_Coding Oct 22 '13 at 21:28
  • If you supply a domain\\username it should fetch that person's profile information and you can then fetch the phone number, assuming that your UPS is mapping in that information from AD. – Eric Alexander Oct 22 '13 at 21:32
  • I think we are having a bug there... cause the Sharepoint Profiles aren't matching Active Directory. It's like they are not syncing. For example a few people have moved departments in AD but in Sharepoint it hasn't shown the changes. – Ben_Coding Oct 22 '13 at 22:16
  • 2
    UPS I shorthanded for user profile service. If information is out of date, ensure that there is a regular sync happening in Central Admin. – Eric Alexander Oct 22 '13 at 22:23
0

Thanks PiracteEric! Looking through Clayton's article helped. The problem was our Synchronization connection. The Sync job was running. But no one ever setup the sync connection. Yikes. Well solved that one.

enter image description here

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.