【问题标题】:Cannot authenticate against Windows domain using ColdFusion 10, IIS 7.5, LDAP无法使用 ColdFusion 10、IIS 7.5、LDAP 对 Windows 域进行身份验证
【发布时间】:2013-06-04 17:10:19
【问题描述】:

我们一直在努力使用 ColdFusion 10 从 Windows 2003 Server (ColdFusion 8) 升级到 Windows 2008。我们终于有了正确的设置来处理和处理我们所有的 ColdFusion 代码,具有自定义错误处理程序,并且 SSL 用作预期的。 但是,当我们开始让一些用户测试不同的应用程序时,我们发现没有域用户可以登录网站,除非他们是本地计算机管理员组的成员。我们有另一个运行 .NET 并正确验证用户的 Windows 2008 Server。我彻底比较了设置,它们是相同的。 它是这样设置的:

  • ColdFusion 服务:所有服务 (5) 都在本地系统下运行,但 ColdFusion 应用程序服务器除外,它在域帐户下运行。
  • IIS:我们有 1 个活动网站(主网站)在其自己的应用程序池集成 .NET 4.0 上运行,作为 LocalSystem 运行。
  • 身份验证:匿名有效,匿名帐户必须是应用程序池标识,否则不会显示任何内容。基本认证已配置,默认域已配置。

感谢任何和所有帮助,因为我们已经为此工作了几个月,并认为迁移已经准备好进行。我的团队中没有人是 ColdFusion 或 IIS 7.5 安装方面的专家。

【问题讨论】:

  • 您能否说明您是如何尝试对您的用户进行身份验证的?您的问题引用了 LDAP,但听起来您正在尝试使用基于 IIS 的身份验证。您是否在 ColdFusion 模板中有登录表单,或者您希望浏览器提示输入凭据(质询/响应)?
  • 哦,很抱歉造成混乱。我们通过 IIS 使用 BASIC 身份验证,该身份验证转到本地 A/D 服务器。我们没有使用表单身份验证或其他任何类似的东西。
  • 当您说“基本身份验证”时,您的意思是“Windows 身份验证”吗?您使用的是 Windows 2008 还是 Windows 2008R2?此外,您不必在 ColdFusion 站点的应用程序池上启用“.NET 4.0”,除非您将 .Net 与 CF 集成(我不知道,我从未使用过 .Net)。我通常将应用程序池设置为“未托管”。
  • 正如@cfvonner 提到的,我们将应用程序池设置为“无托管代码”。我们正在运行 Windows 2008 R2。我们的站点使用基本身份验证和 Windows 身份验证针对我们的域运行。我们对使用 cfhttp 标签的网站使用基本身份验证(它无法处理 Windows 身份验证)。对于用户身份验证,我们使用 Windows Auth。对于基本,只需启用基本身份验证,然后在“授权规则”下拒绝匿名用户并为您的域组/用户添加允许规则。在指定的角色或组下,将它们指定为“域名\组名”。指定用户下为“域名\用户名”。
  • 我不是指 Windows 身份验证;我们正在使用 BASIC(401 挑战)。打开 BASIC 并输入默认域仍然不允许域上的用户访问,即使他们被明确标识为具有查看文件夹的适当权限。

标签: authentication iis coldfusion basic-authentication


【解决方案1】:

经过一番折腾,我在这里找到了答案:What are the proper permissions for ColdFusion 9 on IIS 7.5 with Windows Authentication

我需要授予域用户(这只是一个非常大的 A/D 组)对 CF10 安装位置下的配置文件夹的只读访问权限。从那以后,效果很好!

【讨论】:

    【解决方案2】:

    如果您也对相当稳健的解决方案感兴趣,可以调用以下示例组件 (CFC),它还可以清除可能的注入字符。我们多年来一直在改进它以进行身份​​验证,因此它经过了相当多的考验。

    <cfcomponent output="false">
    
    <cffunction access="public" name="init" output="FALSE" returntype="any" hint="This is the pseudo constructor that allows us to play little object games." >
    
        <cfset variables.ldapserver = application.yoursiteLDAP.server />
        <cfset variables.ldapuser = application.yoursiteLDAP.user />
        <cfset variables.ldappassword = application.yoursiteLDAP.password />
        <cfset variables.ldaptimeout = application.yoursiteLDAP.timeout />
        <cfset variables.ldapsecuremode = application.yoursiteLDAP.securemode />
        <cfset variables.port = application.yoursiteLDAP.port />
    
        <cfreturn This />
    </cffunction>
    
    <cffunction name="authenticate" access="public" output="false" returntype="struct" hint="">
        <cfargument name="username" type="string">
        <cfargument name="password" type="string">
    
        <cfset var returnData = StructNew() />
        <cfset var queryResult = QueryNew('') />
        <cfset var userInfo = "" />
    
        <cfset arguments.username = scrubStringforLDAPQuery(arguments.username) />
    
        <cfset userInfo = retrieveUserInfo(arguments.username) />
    
        <cfset returnData["authenticated"] = false />
        <cfset returnData["detail"] = "" />
        <cfset returnData["user_info"] = QueryNew("") />
    
        <cftry>
                <cfldap
                        action="query"
                        server="#variables.ldapserver#"
                        username="#userInfo.DN#"
                        password="#arguments.password#"
                        filter="(&(uid=#arguments.username#)(objectClass=account))"
                        name="queryResult"
                        attributes="cn,dn,uid,displayName,objectClass,uidNumber"
                        start="dc=yoursite,dc=subdomain,dc=domain,dc=com"
                        maxrows="1"
                        port="#variables.port#"
                        timeout="#variables.ldaptimeout#"
                        secure="#variables.ldapsecuremode#" />
    
                <cfset returnData["authenticated"] = queryResult.RecordCount EQ 1 />
                <cfset returnData["user_info"] = queryResult />
    
                <cfcatch>
                        <cfif FindNoCase("Invalid Credentials",cfcatch.Message) LTE 0>
                                <cfrethrow />
                        </cfif>
                        <cfset returnData["detail"] = cfcatch.Message />
                </cfcatch>
        </cftry>
    
        <cfreturn returnData />
    
    </cffunction>
    
    <cffunction name="retrieveUserInfo" access="public" output="false" returntype="query" hint="">
        <cfargument name="username" type="string">
    
        <cfset var queryResult = QueryNew('') />
    
        <cfset arguments.username = scrubStringforLDAPQuery(arguments.username) />
    
        <cfldap
                action="query"
                server="#variables.ldapserver#"
                username="#variables.ldapuser#"
                password="#variables.ldappassword#"
                filter="(&(uid=#arguments.username#)(objectClass=account))"
                name="queryResult"
                attributes="cn,dn,uid,displayName,objectClass,uidNumber,shadowExpire,gecos,homeDirectory,loginShell"
                start="dc=yoursite,dc=subdomain,dc=domain,dc=com"
                maxrows="10"
                port="#variables.port#"
                timeout="#variables.ldaptimeout#"
                secure="#variables.ldapsecuremode#" />
    
        <cfif queryResult.RecordCount GT 1>
                <cfthrow message="More than 1 user found in LDAP" detail="More than 1 user matched uid=#arguments.username#" />
        </cfif>
    
        <cfreturn queryResult />
    </cffunction>
    
    <cffunction name="retrieveGroupInfo" access="public" output="false" returntype="query" hint="">
        <cfargument name="groupname" type="string">
    
        <cfset var queryResult = QueryNew('') />
    
        <cfset arguments.groupname = scrubStringforLDAPQuery(arguments.groupname) />
    
        <cfldap
                action="query"
                server="#variables.ldapserver#"
                username="#variables.ldapuser#"
                password="#variables.ldappassword#"
                filter="(&(cn=#arguments.groupname#)(objectClass=posixGroup))"
                name="queryResult"
                attributes="cn,dn,objectClass"
                start="dc=yoursite,dc=subdomain,dc=domain,dc=com"
                maxrows="10"
                port="#variables.port#"
                timeout="#variables.ldaptimeout#"
                secure="#variables.ldapsecuremode#" />
    
        <cfif queryResult.RecordCount GT 1>
                <cfthrow message="More than 1 group found in LDAP" detail="More than 1 group matched uid=#arguments.groupname#" />
        </cfif>
    
        <cfreturn queryResult />
    </cffunction>
    
    <cffunction name="scrubStringforLDAPQuery" access="public" output="false" returntype="string" hint="Removes offensive characters from string for use in an LDAP query">
        <cfargument name="stringToScrub" type="string">
        <cfargument name="blockWildcard" type="boolean" default="false">
    
        <cfset replaceCharacterList = ";=" />
    
        <cfif arguments.blockWildcard>
                <cfset replaceCharacterList &= "*" />
        </cfif>
    
        <cfset arguments.stringToScrub = REReplace(arguments.stringToScrub,"[#replaceCharacterList#]","","all") />
    
        <cfreturn arguments.stringToScrub />
    </cffunction>
    
    </cfcomponent>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-20
      • 2016-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多