--- redmine/app/models/auth_source_ldap.rb.orig	2010-02-17 21:53:36.000000000 -0500
+++ redmine/app/models/auth_source_ldap.rb	2010-02-21 16:00:19.000000000 -0500
@@ -35,7 +35,13 @@
     return nil if login.blank? || password.blank?
     attrs = []
     # get user's DN
-    ldap_con = initialize_ldap_con(self.account, self.account_password)
+    if self.account.include? "$login" then
+        logger.debug "LDAP-Auth with User login"
+        ldap_con = initialize_ldap_con(self.account.sub("$login", login), password)
+    else
+        logger.debug "LDAP-Auth with Admin User"
+        ldap_con = initialize_ldap_con(self.account, self.account_password)
+    end
     login_filter = Net::LDAP::Filter.eq( self.attr_login, login ) 
     object_filter = Net::LDAP::Filter.eq( "objectClass", "*" ) 
     dn = String.new
@@ -50,12 +56,14 @@
                :auth_source_id => self.id ] if onthefly_register?
     end
     return nil if dn.empty?
-    logger.debug "DN found for #{login}: #{dn}" if logger && logger.debug?
-    # authenticate user
-    ldap_con = initialize_ldap_con(dn, password)
-    return nil unless ldap_con.bind
-    # return user's attributes
-    logger.debug "Authentication successful for '#{login}'" if logger && logger.debug?
+    if not self.account.include? "$login" then
+      logger.debug "DN found for #{login}: #{dn}" if logger && logger.debug?
+      # authenticate user
+      ldap_con = initialize_ldap_con(dn, password)
+      return nil unless ldap_con.bind
+      # return user's attributes
+      logger.debug "Authentication successful for '#{login}'" if logger && logger.debug?
+    end
     attrs    
   rescue  Net::LDAP::LdapError => text
     raise "LdapError: " + text
