Using Ruby Webrick HTTPAuth with LDAP -
The app I am writing has the ability to display a login popup and it has a strict coded username / password Authentic with constant pair. I want to certify against our central LDAP server. We do not have a base, but we have a binary_dn string of "cn = USERFOO, ou = it, o = corporate", the user / pass variables are passed through the original login box.
I'm trying to do this through ActiveLdap, but I would not mind using any other library, unless I have the credentials via a single signal HTTPAuth from our LDAP server , Because Webrik is fully written in Ruby. Below I am calling a sample of the function. Does anyone have any idea how to do this? Thanks in advance.
Def prizezap_lap (rik, race) authlabel = "LDAP authentication" HTTPAuth.basic_auth (Rick, Race, Athleteb) {| User, pass. ActiveLdap :: Base.setup_connection (: host => 'ldap.internalserver.com' ,: port => 389,: bind_dn = & gt; "cn = # {user}, ou = it, o = corporate ",: Password_block => Proc.new {pass},}} end of return
I thought out of a solution, the person managing our LDAP server provides the wrong lidap connection string, but it still does not work.
The solution I found was that it actually made a connection with very basic verification, it is something that has a very simple ldap authentication popup in pure ruby for someone interested in popup.
Def prizification (rik, race) authlabel = 'LDAP authentication' HTTPAuth.basic_auth (req, res, authlabel) {| User, pass. If pass.to_s! = '' Ldap = Net :: LDAP.new ldap.host = "ldap.serverfoo.com" ldap.port = 389 Results = ldap.bind_as (: base = & gt; "t = basetreefoo" ,: Filter = & gt; ; "Uid = # {user}" ,: password = & gt; pass) if the result ldap = Net :: LDAP.new: host = & gt; "Ldap.serverfoo.com" ,: port = & gt; "38 9" ,: auth => {: Method = & gt; : Simple, User Name = & gt; "",: Password = & gt; "Group" group = "net :: LDAP :: Filter.eq (" cn "," # {user} ") group_type = net :: LDAP :: filter.ec (" Group Membership "," CN = Infra, or = IT, O = Corporate ") Filter = Group_Name & amp; Group_type treebase = "t = basetreefoo" ldap.search (: base = & gt; treebase, filter = & gt; filter). Entry | If the entry 'dn.to_s!' Say, 'success' returns and end and end 'fail'} and
Comments
Post a Comment