Existe-t-il une méthode recommandée (et de préférence gratuite) dans ColdFusion pour accéder à un fichier distant protégé par l'authentification NTLM? La balise cfhttp semble uniquement prendre en charge l'authentification de base.Authentification NTLM dans ColdFusion
Répondre
Cette étiquette CFX - CFX_HTTP5 - devrait faire ce que vous avez besoin. Cela coûte 50 $, mais peut-être que ça vaut le coût? On dirait un petit prix à payer.
Voici un code que je trouve dans:
http://www.bpurcell.org/downloads/presentations/securing_cfapps_examples.zip
Il y a aussi des exemples pour ldap, webservices, et plus .. je vais coller 2 fichiers ici afin que vous puissiez avoir une idée, regarde de code comme ça devrait encore fonctionner.
<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>
C'est le cfc qui pourrait être vous intéresser:
<!---
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>
Cela semble plus pour si je veux sécuriser ma propre application avec NTLM. Ou est-ce que je comprends mal? – Soldarnal
Désolé, j'ai mal lu la question! –
Vous pouvez essayer de suivre les conseils ici: http://cfsilence.com/blog/client/index.cfm/2008/3/17/ColdFusionSharepoint-Integration--Part-1--Authenticating
Voici ce que cela se résume à vous faire:
edit the client-config.wsdd
changement
<transport
name="http"
pivot="java:org.apache.axis.transport.http.HTTPSender">
</transport>
à
<transport
name="http"
pivot="java:org.apache.axis.transport.http.CommonsHTTPSender">
</transport>
Hmm, cela semblait prometteur, mais n'a pas fonctionné pour moi. Peut-être que CF utilise uniquement Axis lors de la création d'une requête SOAP? (J'essaie juste de saisir un fichier texte brut.) – Soldarnal
Si le code de Brandon Purcell qui utilise la classe jrun.security.NTauth
ne fonctionne pas pour vous dans cf9
(il n'a pas pour moi) le correctif est d'utiliser la classe à la place coldfusion.security.NTAuthentication
. Tout a bien fonctionné pour moi.
Je viens de passer une demi-heure à essayer de trouver ce nom de classe! Merci!! –
Dans mon cas, je résolu ce problème en utilisant 'autorisation NTLM Proxy Server'
http://www.tldp.org/HOWTO/Web-Browsing-Behind-ISA-Server-HOWTO-4.html
travail bien pour moi :)
- 1. Authentification NTLM avec GetHttpConnection
- 2. Authentification WCF/basicHttp et NTLM
- 3. IIS -> connecteur -> Tomcat (authentification NTLM)
- 4. Python urllib2 Authentification HTTPS et proxy NTLM
- 5. Authentification NTLM à l'aide de stops wsdl2java CXF
- 6. Authentification NTLM pour une application côté serveur Web
- 7. Java 6 Authentification par proxy NTLM et HTTPS - quelqu'un a-t-il eu le travail?
- 8. Authentification JCIFS NTLM pour les connexions HTTP sur GlassFish (ou tout conteneur de servlet)
- 9. Comment utiliser l'authentification NTLM avec Active Directory
- 10. TWebBrowser et NTLM-authencation
- 11. WCF Identity NTLM Kerberos
- 12. Authentification d'un service Web
- 13. Utilisation de services Web Sharepoint avec Coldfusion
- 14. WCF-BasicHttp NTLM conseils ESB
- 15. CFINVOKE vs java.lang.OutOfMemoryError dans ColdFusion
- 16. XSD pour WSDL dans ColdFusion
- 17. Flash ActionScript Exemple d'authentification NTLM?
- 18. Rapports ColdFusion
- 19. Client JAX-WS pour l'authentification intégrée Windows IIS (NTLM)
- 20. Windows Authentification dans ASP.NET
- 21. Authentification OpenID dans ASP.NET?
- 22. Valeur manquante dans form.fieldnames dans ColdFusion
- 23. Authentification (ou même identification) de la machine cliente dans ASP.NET
- 24. Comment effectuer un défi NTLM sur l'iPhone
- 25. Flex ColdFusion Emplacement CFC
- 26. Authentification des utilisateurs dans ASP.NET
- 27. Authentification unique dans Java EE
- 28. Authentification de l'utilisateur dans Django
- 29. Authentification Windows intégrée dans FireFox
- 30. Cadre HMVC pour Coldfusion?
+1 Il est comme je l'ai fait une fois. Fonctionne bien! –
Ce n'est pas une mauvaise solution; Je l'ai utilisé dans le passé et cela fonctionne. Ce que je voudrais éviter, ce n'est pas tellement le coût monétaire, mais le coût de la maintenance des licences et une dépendance externe. – Soldarnal
Eh bien, vous ne pouvez pas le faire de manière native dans CF, donc vous avez besoin d'une solution tierce comme celle-ci ou vous avez besoin de la vôtre. – ale