SPServices GetUserProfileByName JQuery
Requirement:- Hide the user according to there permission level means if the user have permission in particular group A then one field "SPS-DistinguishedName" have entry like "OU=ServiceAccounts".
I tried to call the function getUserProfileByName with a specified username/AccountName using jquery with SPServices for hide the user form details.
I tried to call the function getUserProfileByName with a specified username/AccountName using jquery with SPServices for hide the user form details.
<script src="/teams/tsc/rintu/InfoPath/Shared%20Documents/jquery.SPServices-0.7.2.js"></script>
<script type="text/javaScript">
$(document).ready(function()
{
$('.ms-spbTree').each(function(){
$(this).find('li').each(function(){
var obj=$(this).attr('id');
var details=getTheUserInfo(obj);
if(details.indexOf("OU=ServiceAccounts")>-1)
{
$(this).hide();
}
});
});
});
function getTheUserInfo(acct){
var ph;
$().SPServices({
operation: 'GetUserProfileByName',
async: false,
accountName: acct,
completefunc: function(xData, Status) {
ph=$(xData.responseXML).find("PropertyData").find("Name[text=SPS-DistinguishedName]").parent().find("Values").text();
}
});
return ph;
}
</script>
No comments:
Post a Comment