coldfusion - 如何判断用户是否属于事件目录中的角色 - 使用 ColdFusion

标签 coldfusion active-directory ldap

如果我在 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/

相关文章:

pdf - 如何从 ColdFusion 结构对象中获取值

java - 从 Activity 目录查询扩展属性

java - 使用tomcat绑定(bind)LDAP进行多认证?

ruby-on-rails - 使用 net-ldap 从 AD 组中删除成员

active-directory - 尝试使用 userPrincipalName 连接时出现 LDAPException

cookies - Cookie 被覆盖 Google Analytics - Coldfusion

regex - 如何使用 ColdFusion 从 XML 字符串中删除所有多余的空格?

apache - 以与多实例 Adob​​e CF 相同的方式设置 Railo

windows-7 - DNS解析在Web浏览器中失败,但是nslookup成功

c# - 如何在 Active Directory 中获取用户的组?