如果我在 IIS 中使用集成身份验证,我如何使用 ColdFusion 确定当前用户是否是特定事件目录角色的一部分。
这类似于在 .net 中使用 User 对象的 IsInRole() 方法 - 如何在 ColdFusion 中完成
最佳答案
执行此操作的唯一方法是使用 cflap 并查询事件目录服务器以获取组列表。获得列表后,您需要对其进行解析以查看该用户是否属于相关组。下面是我为工作人员编写的一些代码和一些评论。值(value)观已经改变以保护无辜者。
<!--- getting the user login id --->
<cfset variables.thisuser = ListLast(cgi.AUTH_USER, "\")>
<!--- this is the group they must be a memberof --->
<cfset variables.groupname = "CN=<the group to search for>">
<!--- list of all groups that the user belongs to, will be populated later --->
<cfset variables.grouplist = "">
<cftry>
<cfldap action="query"
name="myldap"
attributes="memberOf"
start="OU=<your ou>,DC=<your dc>,DC=<your dc>"
scope="subtree"
filter="(sAMAccountName=#variables.thisuser#)"
server="<your AD server ip>"
port="<your AD server port>"
username="<network login if required>"
password="<network password if required>">
<cfset variables.grouplist = myldap.memberOf>
<cfcatch>
</cfcatch>
</cftry>
<cfif FindNoCase(variables.groupname, variables.grouplist)>
<cfcookie name="SecurityCookieName" value="">
</cfif>
关于coldfusion - 如何判断用户是否属于事件目录中的角色 - 使用 ColdFusion,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1235551/