SP2013:spPageContextInfo.userId - 如何获取当前登录用户

时间:2017-12-11 11:01:57

标签: javascript sharepoint sharepoint-2013

我有这部分代码:

function getUser() {
    var userid = _spPageContextInfo.userId;
    //alert(userid);

    var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + userid + ")";
    var requestHeaders = { "accept": "application/json;odata=verbose" };
    $.ajax({
        url: requestUri,
        contentType: "application/json;odata=verbose",
        headers: requestHeaders,
        success: onSuccess,
        error: onError
    }); function onSuccess(data, request) {
        var loginName = data.d.Title;
        var street = data.d.???;
        var city = data.d.???;
        var postalCode = data.d.???;
        var mobilePhone = data.d.???;
        var Email = data.d.Email;
        console.log(loginName);
        console.log(street);
        console.log(city);
        console.log(postalCode);
        console.log(mobilePhone);
        console.log(Email);

    } function onError(error) {
        alert("Error getting user.");
    }
}

我需要的是如何获得除标题和电子邮件之外的其他用户信息..

例如:输出应如下所示:

John Doe (Title)
5th Ave. 100 (street)
New York (city)
123 456 (postalCode)
111 222 333 (mobilePhone)
johndoe@emai.com (Email)

是否可以使用_spPageContextInfo.userId来完成?或者还有其他办法吗?要直接形成AD?

非常感谢!

0 个答案:

没有答案