Here is the code I found in:
http://www.bpurcell.org/downloads/presentations/securing_cfapps_examples.zip
There are also examples for ldap, webservices, etc. I will insert 2 files here so that you can have an idea, the code looks as if it should work anyway.
<cfapplication name="example2" sessionmanagement="Yes" loginStorage="Session"> <cfset Request.myDomain="allaire"> <cfif isdefined("url.logout")> <CFLOGOUT> </cfif> <cflogin> <cfif not IsDefined("cflogin")> <cfinclude template="loginform.cfm"> <cfabort> <cfelse> <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)> <cfelse> <cfset loginmessage="Invalid Login"> <cfinclude template="loginform.cfm"> <cfabort> </cfif> </cfif> </cflogin> <cffunction name="stripSpacesfromList"> <cfargument name="myList"> <cfset myArray=listtoarray(arguments.myList)> <cfloop index="i" from="1" to="#arraylen(myArray)#" step="1"> <cfset myArray[i]=trim(myArray[i])> </cfloop> <cfset newList=arrayToList(myArray)> <cfreturn newList> </cffunction>
This is cfc, which may interest you:
<cfcomponent name="NTSecurity" > <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> <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 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> <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 not right now groups = trim(groups.toString()); groups = mid(groups,2,len(groups)-2); </cfscript> <cfreturn groups> <cfcatch> <cfreturn ""> </cfcatch> </cftry> </cffunction> </cfcomponent>
source share