Add a parameter for optional suppressing of error msg
If multiple LDAP authenticators are used the first ldap authenticator might find you're not validated correctly. Even though a second authentication method provides a successful login you end up with an error message "Invalid username or password".
The report_invalid_credentials parameter one can provide after having applied the patch below allows to suppress the error being generated on the first ldap authenticator. See line 5 and 6
1 ## config snippet, simplified for documentation purposes
2 from MoinMoin.auth.ldap_login import LDAPAuth
3 from farmconfig import FarmConfig
4
5 automation_users_ldap = LDAPAuth(
6 ...,
7 name='ldap_automated', # requires recent 1.8 (e.g. 1.8.7)
8 report_invalid_credentials=False, # don't show error message from this authenticator (requires >1.8.7 or patch, see below)
9 ... )
10 human_users_ldap = LDAPAuth(
11 ...,
12 name='ldap_human', # requires recent 1.8 (e.g. 1.8.7)
13 report_invalid_credentials=True, # optional but set for clarity
14 ...)
15
16 # for old 1.8.x (e.g. 1.8.4) you might need instead of the name=... param:
17 #automation_users_ldap.name ='ldap_automated'
18 #human_users_ldap.name ='ldap_human'
19
20 class FarmConfig(DefaultConfig):
21 #in my case i'm using a farm and want to set ldap authentication per instance
22 ...
23
24 class Config(FarmConfig):
25 # your regular instance config or an instance in a farm
26 auth = [automation_users_ldap, human_users_ldap] #
27 ...
Patch / Changeset
Remco, thanks for the patch! It was added to 1.8 (and will later be merged into 1.9) by:
http://hg.moinmo.in/moin/1.8/rev/0ca159b745e8
Note: I changed the parameter name from "report_invalid_username" to "report_invalid_credentials" and also updated the sample ldap_login snippet.
-- ThomasWaldmann 2010-02-21 16:45:04