简体   繁体   中英

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-2010 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:

  1. Use client object model (OM) for ECMAScript:

  2. Call appropriate method from the UserGroup service (eg GetAllUserCollectionFromWeb or GetUserCollection ) using jQuery:

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM