SP へユーザー オブジェクト (sp.js)
Microsoft SharePoint Foundationでユーザーを表します。
**適用対象:**apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013
var object = new SP.User()
メンバー
Userオブジェクトでは、次のメンバーがあります。
Constructor
Userオブジェクトでは、次のコンスがあります。
コンストラクター |
説明 |
---|---|
Initializes a new instance of the SP.User object. |
メソッド
Userオブジェクトでは、次の方法があります。
メソッド |
説明 |
---|---|
Updates the user with changes that have been made to the user properties. |
プロパティ
Userオブジェクトでは、次のプロパティがあります。
プロパティ |
説明 |
---|---|
This property is not available in SharePoint Online. Gets or sets the email address of the user. |
|
Gets the collection of groups of which the user is a member. |
|
Gets or sets a Boolean value that specifies whether the user is a site collection administrator. |
|
Gets the information of the user that contains the user's name identifier and the issuer of the user's name identifier. |
例
次の例では、現在の 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>
他のリソースのエンドポイント
詳細については、ユーザーのリソースを参照してください。
エンドポイント URI 構造
http://<sitecollection>/<site>/_api/web/sitegroups(groupid)/users(loginname)
HTTP 要求
このリソースには、次の HTTP コマンドがサポートしています。
書式を削除します。
DELETE http://<sitecollection>/<site>/_api/web/sitegroups(groupid)/users(loginname)
書式を結合します。
MERGE http://<sitecollection>/<site>/_api/web/sitegroups(groupid)/users(loginname)
投稿の書式
POST http://<sitecollection>/<site>/_api/web/sitegroups(groupid)/users(loginname)
書式を配置します。
PUT http://<sitecollection>/<site>/_api/web/sitegroups(groupid)/users(loginname)