I have a new requirement from client to insert AD details from the users into a Web Part within a site. I have read that the GetUserProfileByName web service is used for this purpose but when I made the request using jquery - ajax I got 401 Unauthorized.
Code:
function call2WS() {
var soapEnv = "<?xml version='1.0' encoding='utf-8'?> \
<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> \
<soap:Body> \
<GetUserProfileByName xmlns='http://microsoft.com/webservices/SharePointPortalServer/UserProfileService'> \
<AccountName>domain\\username</AccountName> \
</GetUserProfileByName> \
</soap:Body> \
</soap:Envelope>";
var call = $.ajax({
url: "http://sharepoint/_vti_bin/UserProfileService.asmx/GetUserProfileByName",
type: "POST",
dataType: "xml",
username: "domain\\username",
password: "passwd",
data: soapEnv,
headers: {
contentType: "text/xml; charset=\"utf-8\""
}
});
Is this the correct approach to accomplish the requirement? if anyone can give a hint on this would be appreciated.