diff -uNr mantis-1.1.1/core/authentication_api.php www/core/authentication_api.php
--- mantis-1.1.1/core/authentication_api.php	2007-10-19 08:54:58.000000000 +0200
+++ www/core/authentication_api.php	2008-04-25 13:33:50.000000000 +0200
@@ -82,16 +82,27 @@
 		$t_login_method = config_get( 'login_method' );
 
 		if ( false === $t_user_id ) {
-			if ( BASIC_AUTH == $t_login_method ) {
-				# attempt to create the user if using BASIC_AUTH
-				$t_cookie_string = user_create( $p_username, $p_password );
-
-				if ( false === $t_cookie_string ) {
-					# it didn't work
-					return false;
+			if ( BASIC_AUTH == $t_login_method || LDAP == $t_login_method ) {
+				
+				# attempt to create the user if using BASIC_AUTH or LDAP
+				if ( BASIC_AUTH == $t_login_method) {
+					$t_cookie_string = user_create( $p_username, $p_password );
+				} elseif ( LDAP == $t_login_method ) {
+					# get the users' email address as well if using LDAP
+					$email    = ldap_email_from_username( $p_username );
+					$realname = ldap_realname_from_username( $p_username );
+					if ( $email && $realname ) {
+						# Both email and realname exists in LDAP : create mantis user	
+						$t_cookie_string = user_create( $p_username, '', $email, null, false, true, $realname );
+						if ( false === $t_cookie_string ) {
+							# it didn't work
+							return false;
+						}
+					}
 				}
 
-				# ok, we created the user, get the row again
+				# we may have created the user, get the row again
 				$t_user_id = user_get_id_by_name( $p_username );
 
 				if ( false === $t_user_id ) {
@@ -136,6 +147,12 @@
 
 		user_reset_failed_login_count_to_zero( $t_user_id );
 		user_reset_lost_password_in_progress_count_to_zero( $t_user_id );
+		
+		# update user Real Name to value from LDAP (in case it changed) at each login
+		if ( ON == config_get( 'use_ldap_realname' ) ) {
+		  user_set_realname( $t_user_id, ldap_realname_from_username( $p_username ) );
+		}
 
 		# set the cookies
 		auth_set_cookies( $t_user_id, $p_perm_login );
diff -uNr mantis-1.1.1/core/ldap_api.php www/core/ldap_api.php
--- mantis-1.1.1/core/ldap_api.php	2007-10-14 00:36:41.000000000 +0200
+++ www/core/ldap_api.php	2008-04-25 13:37:29.000000000 +0200
@@ -92,6 +92,27 @@
 		return $t_info[0]['mail'][0];
 	}
 
+	# --------------------
+	# Return the real name from LDAP, given a username
+	function ldap_realname_from_username( $p_username ) {
+		$t_ldap_organization	= config_get( 'ldap_organization' );
+		$t_ldap_root_dn	    	= config_get( 'ldap_root_dn' );
+
+		$t_ldap_uid_field = config_get( 'ldap_uid_field', 'uid' );
+		$t_ldap_realname_field = config_get( 'ldap_realname_field', 'cn' );
+		$t_search_filter	= "(&$t_ldap_organization($t_ldap_uid_field=$p_username))";
+		$t_search_attrs		= array( $t_ldap_uid_field, $t_ldap_realname_field, 'dn' );
+		$t_ds           	= ldap_connect_bind();
+
+		$t_sr	= ldap_search( $t_ds, $t_ldap_root_dn, $t_search_filter, $t_search_attrs );
+		$t_info	= ldap_get_entries( $t_ds, $t_sr );
+		ldap_free_result( $t_sr );
+		ldap_unbind( $t_ds );
+
+		return $t_info[0][$t_ldap_realname_field][0];
+	}
+
 	# --------------------
 	# Return true if the $uid has an assigngroup=$p_group tag, false otherwise
 	function ldap_has_group( $p_user_id, $p_group ) {
