2017-12-05 2 views
0

私はJavascriptを使用して記入しているリストに広告からユーザー情報を取得する必要があります。私はSPサービスを利用していますが、現在はサインインしているユーザーのアドレス(ストリート、シティ、郵便番号)、電話番号、電子メールを取得する必要があります。私はSPサービス機能SPGetCurrentUserから電話番号と電子メールを受け取ることができますが、そのアドレスはどうですか?助言がありますか?どうもありがとう!Javascriptを使用して共有ポイントでADプロパティを取得するには?

答えて

0

使用のREST APIと所望の特性を得る:

$.ajax({ 

    url: _spPageContextInfo.webAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/GetMyProperties", 
    method: "GET", 
    headers: { Accept: "application/json;odata=verbose" }, 
    success: function (data) { 
     try { 
      //Get properties from user profile Json response 
      var properties = data.d.UserProfileProperties.results; 
      accountName = GetPropertyVal(properties, "AccountName"); 
      Location = GetPropertyVal(properties, "SPS-Location"); 
      SIP = GetPropertyVal(properties, "SPS-sipAddress"); 

      $("[title='CurrentUser']").val(accountName); 



     } catch (err2) { 

     } 
    }, 
    error: function (jQxhr, errorCode, errorThrown) { 

    } 
}); 


function GetPropertyVal(properties, key) { 
var value = ""; 
for (var i = 0; i < properties.length; i++) { 
    if (properties[i].Key == key) { 
     value = properties[i].Value; 
     break; 
    } 
} 
return value; 
} 
関連する問題