惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
有赞技术团队
有赞技术团队
L
LangChain Blog
C
Check Point Blog
博客园 - 【当耐特】
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
GbyAI
GbyAI
美团技术团队
博客园 - 司徒正美
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
S
SegmentFault 最新的问题
A
About on SuperTechFans
Blog — PlanetScale
Blog — PlanetScale
Hugging Face - Blog
Hugging Face - Blog
博客园 - 叶小钗
腾讯CDC
B
Blog
G
Google Developers Blog
The Cloudflare Blog
P
Proofpoint News Feed

博客园 - Seer Lin

自己开发的ERP系统,有需要的联系 MSCRM2016 取消邮箱强制SSL 不听话的下属辞职记 Windows 7下,巧让家用UPS也支持电脑自动关机 海蜘蛛去广告 [转]SQL2008链接服务器数据同步 asp.net 在IE8 导出excel时的问题 [转]mssql链接服务器 win2008 R2 64位系统下配置DCOM权限 [转]excel 操作类 在excel中,将 长*宽*高 这样的格式列,拆分成3列 将没有产品图片的产品设置为不在前台显示SQL实现 [转]在Reporting Services报表中引用FTP站点上的图片 mscrm js webservic 常用功能 mscrm4.0 判断当前用户角色_示例 mscrm4.0 获取当前登录的用户名 mscrm4.0 用js调用Webservice vs2010 js 代码折叠插件 MSCRM 删除客户数据 MSCRM offline plugin开发注意事项
mscrm 4.0 获取当前用户角色
Seer Lin · 2011-03-16 · via 博客园 - Seer Lin

var script = document.createElement('script');
script.setAttribute(
'runat''server');
script.setAttribute(
'language''javascript');
script.text 
= "function UserHasRole(roleName){var oXml = GetCurrentUserRoles();if(oXml != null){var roles = oXml.selectNodes(\'//BusinessEntity/q1:name\');if(roles != null){for( i = 0; i < roles.length; i++){if(roles[i].text == roleName){return true;}}}}return false;}function GetCurrentUserRoles(){var xml =\"<?xml version=\'1.0\' encoding=\'utf-8\'?><soap:Envelope xmlns:soap=\'http://schemas.xmlsoap.org/soap/envelope/\' xmlns:xsi=\'http://www.w3.org/2001/XMLSchema-instance\' xmlns:xsd=\'http://www.w3.org/2001/XMLSchema\'>\" + GenerateAuthenticationHeader() + \" <soap:Body><RetrieveMultiple xmlns=\'http://schemas.microsoft.com/crm/2007/WebServices\'><query xmlns:q1=\'http://schemas.microsoft.com/crm/2006/Query\' xsi:type=\'q1:QueryExpression\'><q1:EntityName>role</q1:EntityName><q1:ColumnSet xsi:type=\'q1:ColumnSet\'><q1:Attributes><q1:Attribute>name</q1:Attribute></q1:Attributes></q1:ColumnSet><q1:Distinct>false</q1:Distinct><q1:LinkEntities><q1:LinkEntity><q1:LinkFromAttributeName>roleid</q1:LinkFromAttributeName><q1:LinkFromEntityName>role</q1:LinkFromEntityName><q1:LinkToEntityName>systemuserroles</q1:LinkToEntityName><q1:LinkToAttributeName>roleid</q1:LinkToAttributeName><q1:JoinOperator>Inner</q1:JoinOperator><q1:LinkEntities><q1:LinkEntity><q1:LinkFromAttributeName>systemuserid</q1:LinkFromAttributeName><q1:LinkFromEntityName>systemuserroles</q1:LinkFromEntityName><q1:LinkToEntityName>systemuser</q1:LinkToEntityName><q1:LinkToAttributeName>systemuserid</q1:LinkToAttributeName><q1:JoinOperator>Inner</q1:JoinOperator><q1:LinkCriteria><q1:FilterOperator>And</q1:FilterOperator><q1:Conditions><q1:Condition><q1:AttributeName>systemuserid</q1:AttributeName><q1:Operator>EqualUserId</q1:Operator></q1:Condition></q1:Conditions></q1:LinkCriteria></q1:LinkEntity></q1:LinkEntities></q1:LinkEntity></q1:LinkEntities></query></RetrieveMultiple></soap:Body></soap:Envelope>\";var xmlHttpRequest = new ActiveXObject(\'Msxml2.XMLHTTP\');xmlHttpRequest.Open(\'POST\', \'/mscrmservices/2007/CrmService.asmx\', false);xmlHttpRequest.setRequestHeader(\'SOAPAction\',\'http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple\');xmlHttpRequest.setRequestHeader(\'Content-Type\', \'text/xml; charset=utf-8\');xmlHttpRequest.setRequestHeader(\'Content-Length\', xml.length);xmlHttpRequest.send(xml);var resultXml = xmlHttpRequest.responseXML;return(resultXml);}function GetCurrentUserId(){var soapBody = \"<soap:Body><Execute xmlns=\'http://schemas.microsoft.com/crm/2007/WebServices\'><Request xsi:type=\'WhoAmIRequest\' /></Execute></soap:Body>\";var soapXml = \"<soap:Envelope  xmlns:soap=\'http://schemas.xmlsoap.org/soap/envelope/\' xmlns:xsi=\'http://www.w3.org/2001/XMLSchema-instance\' xmlns:xsd=\'http://www.w3.org/2001/XMLSchema\'>\" + GenerateAuthenticationHeader() + soapBody + \"</soap:Envelope>\";var xmlhttp = new ActiveXObject(\'Msxml2.XMLHTTP\');xmlhttp.open(\'POST\', \'/MSCRMservices/2007/crmservice.asmx\', false);xmlhttp.setRequestHeader(\'Content-Type\', \'text/xml;charset=utf-8\');xmlhttp.setRequestHeader(\'SOAPAction\', \'http://schemas.microsoft.com/crm/2007/WebServices/Execute\');xmlhttp.send(soapXml);xmlDoc= new ActiveXObject(\'Microsoft.XMLDOM\');xmlDoc.async=false;xmlDoc.loadXML(xmlhttp.responseXML.xml);return xmlDoc.getElementsByTagName(\'UserId\')[0].childNodes[0].nodeValue;}"
document.head 
= document.documentElement.firstChild;
document.head.appendChild(script);