2 Replies Latest reply on Feb 29, 2012 1:34 PM by Ken.Hogan

    Switch LDAP from Novell NDS to Microsoft AD

    Ken.Hogan

      I am running ColdFusion MX on Windows 2008 R2.  I am not the original programmer or one by any means.  I have some LDAP code on my Intranet that authenticates users to Novell NDS and creates local cookies.  I need to decommision and power off the Novell servers and NDS.  Whne I try and change the LDAP code to look at AD I just can't get it to work.

       

      Here is the original code that does work. Any suggestions would be greatly appreciated.  The error I get is "Element GIVENNAME is undefined in LDAPLOGIN”

       

      Created by:   Nate Weiss (NMW)

        Please Note:  Executes for every page request

      --->

       

      <cfif cgi.auth_user IS "">

                      Auth Error

                      <cfabort>

       

      <cfelse>

       

                      <cfscript>

                                                      //<!--- setting basic LDAP server attributes --->                

                                                      root = "ou=boston,o=company";                         

                                                      servername = "hermes.company.com";                           

                                                     

                                                      //<!--- Attributes must include uid and dn.  These are used within the 2 authorization queries. --->                                

                                                      attributes = "cn,dn,givenName,sn,workforceID,mail";                                                   

                                                     

                                                      //<!--- passing the username and password of the user to authenticate --->                      

                                                      uid = "#REPLACE(cgi.auth_user,"COMPANY\","","ALL")#";                       

                                                      password = "";                                                 

                                                     

                                                      //<!--- this filter will look in the objectclass for the user's ID --->                               

                                                      filter = "(&(objectclass=*)(cn=#uid#))";                                                                                                

                                                     

                                                      //<!--- use directory manager id to allow a read of the password to authenticate users --->                         

                                                      LDAP_username = "cn=directory manager";                      

                                                      LDAP_password = "password";

                      </cfscript>                         

       

                      <cfif Not IsDefined("cookie.comp_empn")>

                                      <cftry>                

                                                      <cfldap action="QUERY"                                                              

                                                                                                                       name="LDAPLogin"

                                                                                                                       attributes="#attributes#"

                                                                                                                       start="#root#"

                                                                                                                       scope="SUBTREE"          

                                                                                                                       server="#servername#"

                                                                                                                       filter="#filter#">

                                                      <cfcatch type="Any">                                  

                                                                      <cfset UserSearchFailed = true>                              

                                                      </cfcatch>

                                      </cftry>                              

       

                                      <!--- ContactID and First Name, in structure --->

                                      <cfcookie name="UserAuth" Value="True" domain="company.com" expires="1" >

                                      <cfcookie name="berg_fname" value="#LDAPLogin.givenName#" domain="company.com" expires="1">

                                      <cfcookie name="berg_lname" value="#LDAPLogin.sn#" domain="company.com" expires="1">

                                      <cfcookie name="berg_empn" value="#LDAPLogin.workforceID#" domain="company.com" expires="1">

                                      <cfcookie name="berg_email" value="#LDAPLogin.mail#" domain="company.com" expires="1">       

                                      <cfcookie name="UserName" value="#uid#" domain="company.com" expires="never">

                      </cfif>

      </cfif>

       

      <CFSET CRMDATABASE = "VISION">

      <CFSET TransDATABASE = "TRANSMITTAL">

      <CFSET DocDBDatabase = "DocumentDB">

      <CFSET ARCHIVEDB = "JobArchive">

      <CFSET root = "projects.company.com/documentlogs">

      <CFSET DocDBIconPath = "http://projects.company.com/documentlogs/images/icons">

      <CFSET CompanyName = "Bergmeyer Associates, Inc.">

       

      <!--- Name our app, and enable Session variables --->

      <CFAPPLICATION

        NAME="CompanyWebApp"

        SESSIONMANAGEMENT="Yes">

       

      <CFIF cgi.REMOTE_ADDR IS "XXX.XX.XX.133" OR cgi.REMOTE_ADDR IS "XXX.XX.XX.134" OR cgi.REMOTE_ADDR IS "XXX.XX.XX.135">

                      <CFLOGIN cookiedomain="company.com">

                                      <CFLOGINUSER

                                                      NAME="000,Administrator"

                                                      PASSWORD="password"

                                                      ROLES="">

                      </CFLOGIN>              

      </cfif>

      <CFINCLUDE TEMPLATE="VarPassingFunctions.cfm">

       

      <CFIF SERVER_PORT IS NOT 443 AND NOT IsDefined("nossl")>

                      <CFOUTPUT>

                      <SCRIPT>

                      document.location.href='https://#cgi.server_name##cgi.script_name#<cfif cgi.QUERY_STRING is NOT "">?#cgi.QUERY_STRING#</cfif>'

                      </SCRIPT>

                      </CFOUTPUT>

                      <CFABORT>

      </CFIF>

       

      PLEASE HELP!!