I'm using LDAP over ldaps and with user/password and I didn't need to tweak any of the gitorious code. So, this *shouldn't* be needed AFAIK.
One thing you do want to do is update the LDAP library. I already put in a merge request. But with the old 0.0.4 LDAP library, I would get werid errors.
The upgrade is not difficult, but you need to pay attention because the LDAP library has changed name..
At first, I wanted to use a ldap-user for logging in, like you suggested. But then I realized that you can just login as the actual user. We configured the authentication.yml as:
methods:
- adapter: Gitorious::Authentication::LDAPAuthentication
server: server-name :)
port: 636
base_dn: dc=companyname,dc=com
login_attribute: uid
distinguished_name_template: "uid={},ou=people,dc=company,dc=com"
attribute_mapping:
mail: email
encryption: simple_tls
(I changed the sername and the DNs)
Hope this will help you.
Thanks,
Bas
> --
> To post to this group, send email to gito...@googlegroups.com
> To unsubscribe from this group, send email to
> gitorious+...@googlegroups.com
On Tue, Mar 6, 2012 at 2:55 AM, JayP <boso...@gmail.com> wrote:
> [...]
> Here is the code that I have:
>
> def valid_credentials?(username, password)
> return false if password.blank?
> @connection = @connection_type.new({:encryption =>
> @encryption,
> :host => @server,
> :port => @port,
> :base => @base_dn})
> @connection.auth(@ldap_server_user, @ldap_server_pass)
> result = @connection.bind_as(:filter =>
> "(sAMAccountName=#{username})", :password => password)
> result ? true : false
> end
>
> I had to create new instance variables: @ldap_server_user and
> @ldap_server_pass which I set in authentication.yml these are
> credentials I have to use to bind to the ldap server. Then I use the
> actual user and password for the user trying to login to bind_as which
> will validate the user.
Sorry I came to this a bit late. There is a merge request (181) to
get this into mainline here:
https://gitorious.org/gitorious/mainline/merge_requests/181
I guess this is kind of moot as you seem to have already solved your
own problem :)
Cheers,
Martin