문제

NTLM 인증에 의해 보호되는 원격 파일에 액세스하기 위해 냉담에 권장되는 (바람직하게는 자유롭게) 방법이 있습니까? CFHTTP 태그는 기본 인증 만 지원하는 것으로 보입니다.

도움이 되었습니까?

해결책

이 CFX 태그 - CFX_HTTP5 - 필요한 일을해야합니다. $ 50의 비용이 들지만 아마도 비용이 가치가 있습니까? 지불해야 할 작은 가격처럼 보입니다.

다른 팁

다음은 내가 찾은 몇 가지 코드입니다.

http://www.bpurcell.org/downloads/presentations/securing_cfapps_examples.zip

LDAP, WebServices 등에 대한 예도 있습니다.

<cfapplication name="example2" sessionmanagement="Yes" loginStorage="Session">
<!-- Application.cfm -->
<!-- CFMX will check for authentication with each page request. -->
<cfset Request.myDomain="allaire">

<cfif isdefined("url.logout")>
    <CFLOGOUT>
</cfif>


<cflogin>
   <cfif not IsDefined("cflogin")>
      <cfinclude template="loginform.cfm">
      <cfabort>
   <cfelse>
      <!--Invoke NTSecurity CFC -->
        <cfinvoke component = "NTSecurity" method = "authenticateAndGetGroups"
            returnVariable = "userRoles" domain = "#Request.myDomain#"
            userid = "#cflogin.name#" passwd = "#cflogin.password#">
        <cfif userRoles NEQ "">
            <cfloginuser name = "#cflogin.name#" password = "#cflogin.password#" roles="#stripSpacesfromList(userRoles)#">
            <cfset session.displayroles=stripSpacesfromList(userRoles)><!--- for displaying roles only --->
        <cfelse>
            <cfset loginmessage="Invalid Login">
            <cfinclude template="loginform.cfm">
            <cfabort>
        </cfif>
   </cfif>
</cflogin>

<!-- strips leading & trailing spaces from the list of roles that was returned -->
<cffunction name="stripSpacesfromList">
    <cfargument name="myList">
    <cfset myArray=listtoarray(arguments.myList)>
    <cfloop index="i" from="1" to="#arraylen(myArray)#" step="1">
        <!--- <cfset myArray[i]=replace(trim(myArray[i]), " ", "_")> 
        out<br>--->
        <cfset myArray[i]=trim(myArray[i])>
    </cfloop>
    <cfset newList=arrayToList(myArray)>
    <cfreturn newList>
</cffunction>

이것은 당신에게 관심을 가질 수있는 CFC입니다.

<!--- 
This component implements methods for use for NT Authentication and Authorization.

$Log: NTSecurity.cfc,v $
Revision 1.1  2002/03/08 22:40:41  jking
Revision 1.2  2002/06/26 22:46  Brandon Purcell
component for authentication and authorization
--->

<cfcomponent name="NTSecurity" >

        <!---  Authenticates the user and outputs true on success and false on failure. --->
        <cffunction name="authenticateUser" access="REMOTE" output="no" static="yes" hint="Authenticates the user." returntype="boolean">
                <cfargument name="userid" type="string" required="true" />
                <cfargument name="passwd" type="string" required="true" />
                <cfargument name="domain" type="string" required="true" />
                <cftry> 
                        <cfscript>
                        ntauth = createObject("java", "jrun.security.NTAuth");
                        ntauth.init(arguments.domain);
                        // authenticateUser throws an exception if it fails, 
                        ntauth.authenticateUser(arguments.userid, arguments.passwd);
                        </cfscript>

                <cfreturn true>
                <cfcatch>
                <cfreturn false>
                </cfcatch>
                </cftry>  
        </cffunction>

        <!--- 
                Authenticates the user and outputs true on success and false on failure.
        --->
        <cffunction access="remote" name="getUserGroups" output="false" returntype="string" hint="Gets user groups." static="yes">
                <cfargument name="userid" type="string" required="true" />
                <cfargument name="domain" type="string" required="true" />

                 <cftry>
                        <cfscript>
                        ntauth = createObject("java", "jrun.security.NTAuth");
                        ntauth.init(arguments.domain);
                        groups = ntauth.GetUserGroups(arguments.userid); 
                        // note that groups is a java.util.list, which should be 
                        // equiv to a CF array, but it's not right now???
                        groups = trim(groups.toString());
                        groups = mid(groups,2,len(groups)-2);
                        </cfscript>
                       <cfreturn groups>
                <cfcatch>
                        <cflog text="Error in ntsecurity.cfc method getUserGroups - Error: #cfcatch.message#" type="Error" log="authentication" file="authentication" thread="yes" date="yes" time="yes" application="no"> 
                        <cfreturn "">
                 </cfcatch>
                </cftry>  

        </cffunction>

        <!--- 
                This method combines the functionality of authenticateUser and getUserGroups. 
        --->
        <cffunction access="remote" name="authenticateAndGetGroups" output="false" returntype="string" hint="Authenticates the user and gets user groups if it returns nothing the user is not authticated" static="yes">
                <cfargument name="userid" type="string" required="true" />
                <cfargument name="passwd" type="string" required="true" />
                <cfargument name="domain" type="string" required="true" />  
                 <cftry>  
                        <cfscript>
                        ntauth = createObject("java", "jrun.security.NTAuth");
                        ntauth.init(arguments.domain);
                        // authenticateUser throws an exception if it fails, 
                        // so we don't have anything specific here
                        ntauth.authenticateUser(arguments.userid, arguments.passwd);
                        groups = ntauth.GetUserGroups(arguments.userid);

                        // note that groups is a java.util.list, which should be 
                        // equiv to a CF array, but it's not right now
                        groups = trim(groups.toString());
                        groups = mid(groups,2,len(groups)-2);
                        </cfscript>     
                <cfreturn groups>
                <cfcatch>
                        <cfreturn "">
                 </cfcatch>
                </cftry>   

        </cffunction>

</cfcomponent>

Brandon Purcell의 코드 인 경우 jrun.security.NTauth 수업은 당신을 위해 작동하지 않습니다 cf9 (나를 위해서는 안된다) 고정은 사용하는 것입니다. coldfusion.security.NTAuthentication 대신 수업. 모든 것이 나에게 잘 작동했습니다.

여기에서 지침을 따라 시도 할 수 있습니다. http://cfsilence.com/blog/client/index.cfm/2008/3/17/coldfusionsharepoint-integration--part-1-- authenticating

다음은 다음과 같은 일입니다.

edit the client-config.wsdd

변화

<transport 
    name="http" 
    pivot="java:org.apache.axis.transport.http.HTTPSender">
</transport>

에게

<transport 
    name="http" 
    pivot="java:org.apache.axis.transport.http.CommonsHTTPSender">
</transport>

제 경우에는 'NTLM Authorization Proxy Server'를 사용 하여이 문제를 해결했습니다.

http://www.tldp.org/howto/web-browsing-behind-isa-server-howto-4.html

나를 위해 잘 작동합니다 :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top