--- Gemfile.orig	2014-05-18 18:41:03.150000000 +0200
+++ Gemfile	2014-05-18 18:41:42.840000000 +0200
@@ -35,7 +35,8 @@
 gem 'gitlab-grack', '~> 2.0.0.pre', require: 'grack'
 
 # LDAP Auth
-gem 'gitlab_omniauth-ldap', '1.0.4', require: "omniauth-ldap"
+# Patched for attributes mapping customization
+gem 'gitlab_omniauth-ldap', '1.0.4', require: 'omniauth-ldap', git: 'https://github.com/jirutka/omniauth-ldap.git', ref: 'b55852bfc9b46ecf790a2c5526386702350eab89'
 
 # Git Wiki
 gem "gitlab-gollum-lib", "~> 1.1.0", require: 'gollum-lib'
--- Gemfile.lock.orig	2014-05-18 18:42:08.100000000 +0200
+++ Gemfile.lock	2014-05-18 18:43:35.330000000 +0200
@@ -5,6 +5,17 @@
   specs:
     charlock_holmes (0.6.9.4)
 
+ GIT
+  remote: https://github.com/jirutka/omniauth-ldap.git
+  revision: b55852bfc9b46ecf790a2c5526386702350eab89
+  ref: b55852bfc9b46ecf790a2c5526386702350eab89
+  specs:
+    gitlab_omniauth-ldap (1.0.4)
+      net-ldap (~> 0.3.1)
+      omniauth (~> 1.0)
+      pyu-ruby-sasl (~> 0.0.3.1)
+      rubyntlm (~> 0.1.1)
+
 GIT
   remote: https://github.com/gitlabhq/markup.git
   revision: 61ade389c1e1c159359338f570d18464a44ddbc4
@@ -190,11 +201,6 @@
       gitlab-linguist (~> 3.0.0)
       rugged (~> 0.19.0)
     gitlab_meta (6.0)
-    gitlab_omniauth-ldap (1.0.4)
-      net-ldap (~> 0.3.1)
-      omniauth (~> 1.0)
-      pyu-ruby-sasl (~> 0.0.3.1)
-      rubyntlm (~> 0.1.1)
     gon (5.0.1)
       actionpack (>= 2.3.0)
       json
@@ -588,7 +594,7 @@
   gitlab-linguist (~> 3.0.0)
   gitlab_git (~> 5.4.0)
   gitlab_meta (= 6.0)
-  gitlab_omniauth-ldap (= 1.0.4)
+  gitlab_omniauth-ldap (= 1.0.4)!
   gon (~> 5.0.0)
   grape (~> 0.6.1)
   grape-entity (~> 0.3.0)
--- config/gitlab.yml.example.orig	2014-05-18 18:44:01.500000000 +0200
+++ config/gitlab.yml.example	2014-05-18 18:44:44.250000000 +0200
@@ -127,6 +127,10 @@
     method: 'ssl' # "tls" or "ssl" or "plain"
     bind_dn: '_the_full_dn_of_the_user_you_will_bind_with'
     password: '_the_password_of_the_bind_user'
+    mapping:
+      username: 'uid'
+      name: 'cn'
+      email: 'mail'
     # If allow_username_or_email_login is enabled, GitLab will ignore everything
     # after the first '@' in the LDAP username submitted by the user on login.
     #
--- config/initializers/devise.rb.orig	2014-05-18 18:45:35.080000000 +0200
+++ config/initializers/devise.rb	2014-05-18 18:46:06.530000000 +0200
@@ -223,6 +223,7 @@
       method:   Gitlab.config.ldap['method'],
       bind_dn:  Gitlab.config.ldap['bind_dn'],
       password: Gitlab.config.ldap['password'],
+      mapping:  Gitlab.config.ldap['mapping'],
       name_proc: email_stripping_proc
   end
 
--- lib/gitlab/ldap/user.rb.orig	2014-05-18 18:46:48.820000000 +0200
+++ lib/gitlab/ldap/user.rb	2014-05-18 18:47:22.240000000 +0200
@@ -97,6 +97,10 @@
           'ldap'
         end
 
+        def username
+          (auth.info.username || auth.info.nickname).to_s.force_encoding('utf-8')
+        end
+
         def raise_error(message)
           raise OmniAuth::Error, "(LDAP) " + message
         end