I'm using Devise with LDAP authentication in a Rails 4 application. The ldap.yml looks like
development:
host: my.ldap.server
port: 636
attribute: sAMAccountName
base: OU=Accounts,DC=my,DC=ldap,DC=server
admin_user: CN=ServiceAccount,OU=LDAP,OU=Service Accounts,DC=my,DC=ldap,DC=server
admin_password: super_secret_password
ssl: true
production:
...
I want to be able to access this programmatically, but I cannot figure out how to do it. I can access by reading directly from the file by doing
However, this is not 100% accurate because if the values in the file had changed without the Rails server being restarted, the "live" values that Rails is actually using would be different.
How can I get to these "live" values? I can't find anything on this.
Devise.ldap_configwork on your console? AndUser.ldap_config? Also, I don't see a big problem accessing theyamlfile directly: if you change that values, you'll need to restart the server in any case!Devise.ldap_configgives nil andUser.ldap_configdoes not exist. Yeah, it's not that big of a deal, but something about it bugs me.Devise::LDAP::Connection.new.ldap? That should let you accessDevise::LDAP::Connection.new.ldap.host,Devise::LDAP::Connection.new.ldap.portand so on.