admin管理员组

文章数量:1310143

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

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

Share Improve this question edited Feb 1, 2011 at 21:36 user229044 240k41 gold badges344 silver badges346 bronze badges asked Feb 1, 2011 at 18:42 Ishaan PunianiIshaan Puniani 6582 gold badges10 silver badges23 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

There are two ways to do it:

  1. 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 bine appropriate pieces of code.

  2. Call appropriate method from the UserGroup service (e.g. GetAllUserCollectionFromWeb or GetUserCollection) 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>",
        pletefunc: 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").autoplete({
        source: data,
        select: function(e, ui){
            var tmpHTML = ui.item['value'];
            $("#person_info").html(tmpHTML);
        }
    });
}
</script>

本文标签: javascripthow to get users from sharepoint user profile db using jqueryStack Overflow