Hello all,
I am building ColdFusion apps for a closed network (no connection to the cloud) and am using this code for authentication. It checks the logged in Windows user against Active Directory and returns user information (if user found) and sets an appropriate login message. The idea is for my users not to have to login at all. The system just knows who they are and lets them in if authorized. Any ideas on how to incorporate this into PLUM framework?
Login.cfm
<cfscript>
function string2array2string(str){
var CharArray = ArrayNew(1);
var string = "";
for (c = 1; c LTE Len(str); c = c +1){
CharArray[c] = Mid(str, c, 1);
}
for (i = 1; i LTE 5; i = i+1){
ArrayDeleteAt(CharArray, 1);
}
for (x = 1; x LTE ArrayLen(CharArray); x = x+1){
String=String & CharArray[x] ;
}
return String;
}
</cfscript>
<cfset user = string2array2string(#cgi.auth_user#)>
<cfparam type="string" name="LoginMessage" default="">
<cfldap action="">
name="GetUserInfo"
attributes="dn"
start="dc=JPRA,dc=local"
Scope="subtree"
filter="(&(objectclass=user)(samaccountname=#user#))"
server="acs-srv.JPRA.local"
Port="389"
username="[EMAIL PROTECTED]"
password="">
<cfif #getuserinfo.recordcount# gt 0>
<cftry>
<cfldap action="">
name="AuthenticateUser"
attributes="givenname,samaccountname,dn,cn,mail, telephoneNumber"
start="dc=JPRA,dc=local"
maxrows="1"
Scope="subtree"
filter="(&(objectclass=user)(samaccountname=#user#))"
server="acs-srv.JPRA.local"
Port="389"
username="[EMAIL PROTECTED]"
password="">
<cfset LoginMessage = "User Authentication Passed">
<cfcatch type="any">
<cfset LoginMessage = "User Authentication Failed">
</cfcatch>
</cftry>
<cfelse>
<cfset LoginMessage = "Username not found"> </cfif>
<html>
<head>
<title>Active Directory Login</title>
</head>
<body>
Login Status:<br><br>
<cfoutput>#LoginMessage#</cfoutput> <br><br> <cfif #getuserinfo.recordcount# gt 0 AND #LoginMessage# neq "User Authentication Failed">
<!--Put some code here-->
</cfif>
</body>
</html>
Cheers,
Dan
P.S. I am really looking forward to seeing where you take the next version of PLUM from here.
