zoukankan      html  css  js  c++  java
  • 深入浅出SharePoint——利用jQuery访问SharePoint Web Service获取用户信息

    function document.onkeyup() {
        if (window.event.keyCode == 9) {
            var fldAD = $(document).find(".ms-formtable").children().find("input[title='Title']")[0].value;
            if (fldAD != "") {
                GetUserProfileByName(fldAD);
            }
        }
    }
    
    $(document).ready(function () {
        
    
    });
    
    
    
    function GetUserProfileByName(accountName) {
        //Administrator
        //Build the URL of the Lists.asmx web service.
        //This is done by stripping the last two parts (/doclib/page) of the URL.
        var hrefParts = window.location.href.split('/');
        var wsURL = hrefParts[0] + "/_vti_bin/UserProfileService.asmx";    //URL:http://Minda/_vti_bin/UserProfileService.asmx
        //The SOAP Envelope to send to the Lists.asmx web service.
        //Tip: this XML can be copied from /_vti_bin/lists.asmx?op=GetListCollection
        var soapEnv =
            "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>"
                + "<soapenv:Body>"
                    + "<GetUserProfileByName xmlns='http://microsoft.com/webservices/SharePointPortalServer/UserProfileService'>"
                    + "<AccountName>" + accountName + "</AccountName>"
                    + "</GetUserProfileByName>"
                + "</soapenv:Body>"
            + "</soapenv:Envelope>";
        //Do the web service call async.
        $.ajax({
            url: wsURL,
            type: "POST",
            dataType: "xml",
            data: soapEnv,
            complete: processResult,
            contentType: "text/xml; charset=\"utf-8\""
        });
    }
    
    function processResult(xData, status) {
        var properties = $(xData.responseXML).find("PropertyData");
        $(properties).filter(
            function () {
                return "FirstName" == $(this).find("Name").text();
            }).each(function () {
                $(document).find(".ms-formtable").children().find("input[title='CostCenter']")[0].value = $(this).find("Value").text();
            });
    }
    

      

  • 相关阅读:
    Mysql存储过程详解
    自动化测试——人人都可自制“呼死你”
    Apktool(1)——Apktool的安装
    Apktool(2)——使用前必须知道的apk知识
    写博是种心情
    webpack使用tree shaking的问题。及关于UglifyJs不支持ES6的解决方案。
    angular2 笔记
    angular2 content projection
    angular2aotwebpack 生产环境下编译angular2
    ionic2配置问题集
  • 原文地址:https://www.cnblogs.com/mingle/p/2633823.html
Copyright © 2011-2022 走看看