SP へUserCollection オブジェクト (sp.js)

SP へユーザー オブジェクト (sp.js)のコレクションを表します。

**適用対象:**apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013

var object = new SP.UserCollection()

メンバー

UserCollectionオブジェクトでは、次のメンバーがあります。

Constructor

UserCollectionオブジェクトでは、次のコンスがあります。

コンストラクター

説明

UserCollection

このメンバーは内部使用のために予約済みです。ユーザーのコードから直接使用されるものではありません。

メソッド

UserCollectionオブジェクトでは、次の方法があります。

メソッド

説明

追加します。

Adds the user specified by the user creation information parameter to the collection.

addUser

Adds the specified user to the collection.

getByEmail

Gets the user with the specified email address.

getById

Gets the user with the specified member identifier (ID).

getByLoginName

Gets the user with the specified login name.

itemAt

Gets the user at the specified index of the collection.

削除します。

Removes the specified user from the collection.

removeById

Removes the user with the specified ID.

removeByLoginName

Removes the user with the specified login name.

プロパティ

UserCollectionオブジェクトでは、次のプロパティがあります。

プロパティ

説明

childItemType

アイテム

Gets the user at the specified index of the collection.

次の例では、現在の Web サイトの閲覧者グループに現在のユーザーを追加するアプリケーション ページの [入力] ボタンを作成します。

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<script type="text/ecmascript" language="ecmascript">

var user;
var visitorsGroup;

function runCode() {

     var clientContext = new SP.ClientContext();
     var groupCollection = clientContext.get_web().get_siteGroups();
     // Get the visitors group, assuming its ID is 4.
     visitorsGroup = groupCollection.getById(4);
     user = clientContext.get_web().get_currentUser();
     var userCollection = visitorsGroup.get_users();
     userCollection.addUser(user);

     clientContext.load(user);
     clientContext.load(visitorsGroup);
     clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

}

function onQuerySucceeded() {
    alert(user.get_title() + " added to group " + visitorsGroup.get_title());
}

function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

</script>

    <input id="Button1" type="button" value="Run Code" onclick="runCode()" />

</asp:Content>

他のリソースのエンドポイント

詳細については、 UserCollection リソースを参照してください。

エンドポイント URI 構造

http://<sitecollection>/<site>/_api/web/sitegroups(groupid)/users

HTTP 要求

このリソースには、次の HTTP コマンドがサポートしています。

書式を取得します。

GET http://<sitecollection>/<site>/_api/web/sitegroups(groupid)/users

投稿の書式

POST http://<sitecollection>/<site>/_api/web/sitegroups(groupid)/users