how to get users from sharepoint user profile db using jquery
i just want to know: Is there any way to get a SharePoint user using JavaScript/jQuery from default sharepoint-开发者_如何学JAVA2010 user profile DB?
My requirement is to form an array of all SharePoint site users (user name) and use this array in a java function (that run behind the page at client side ) as a data source for a SPServices function.
Please provide any feasible solution or any other approach for building the array for JavaScript.
thanks
There are two ways to do it:
Use client object model (OM) for ECMAScript:
- Get all users and groups client object model sharepoint 2010
SharePoint 2010: Client Object Model for JavaScript (ECMAScript)
The first article explains how to retrieve information about SharePoint users using OM and the second one shows how to use OM from JavaScript - you have to combine appropriate pieces of code.
Call appropriate method from the UserGroup service (e.g.
GetAllUserCollectionFromWeb
orGetUserCollection
) using jQuery:- Calling the SharePoint Web Services with jQuery
- Consuming WCF / ASMX / REST service using jQuery
- Calling WCF Service using jQuery in Sharepoint Applications
Using SPServices from codeplex:
<script type="text/javascript">
$(document).ready (function() {
$().SPServices({
operation: "GetListItems",
async: true,
listName: "User Information List",
CAMLViewFields: "<ViewFields>" +
"<FieldRef Name='Title' />" +
"</ViewFields>",
completefunc: AttachMembersAutoComplete
});
});
function AttachMembersAutoComplete(xmlResponse) {
var domElementArray = $( "[nodeName=z:row]", xmlResponse.responseXML );
var dataMap = domElementArray.map(function() {
return {
value: $(this).attr('ows_Title'),
};
});
var data = dataMap.get();
$("input#inputMembersAutoComplete").autocomplete({
source: data,
select: function(e, ui){
var tmpHTML = ui.item['value'];
$("#person_info").html(tmpHTML);
}
});
}
</script>
精彩评论