2013-10-10 44 views
1

我使用LDAP對我的應用程序中的用戶進行身份驗證。使用LDAP時捕獲錯誤密碼

<cftry> 
    <cfldap action="query" 
     name  ="qryAuth" 
     attributes="cn,displayname,mail" 
     start  ="DC=corp,DC=com" 
     server ="#LDAPserver#" 
     filter = "(cn=#arguments.EID#)" 
     username ="corp\#arguments.EID#" 
     password ="#arguments.password#"> 

    <cfset this.addlog(arguments.EID, "Success on #LDAPserver#")> 
    <cfreturn true> 

    <cfcatch> 

     <cfset this.addlog(arguments.EID, "#cfcatch.message# on #LDAPserver#")> 

     <cfif cfcatch.message CONTAINS "error code 49"> 

錯誤代碼49是用戶輸入錯誤的密碼時。每次運行時都會記錄一個錯誤。有沒有辦法通過LDAP檢查密碼而不使用try/catch?

+0

我剛剛檢查了我們做的方式,我們使用try/catch。 –

+0

我總是使用try/catch。有沒有你不想這樣做的理由?你總是可以檢查不同的錯誤來執行不同的邏輯(就像你在做的那樣)。 –

+0

我不喜歡每個catch語句都記錄在CF管理員中。 –

回答

0

編寫一個預分析插件,在服務器執行操作之前執行BIND,並設置一個衆所周知的條件,指出他的BIND將失敗。專業品質的LDAP服務器提供了開箱即用的功能。