Username and LDAP (Alternative Username)

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Suggested Hosts
masterkeedu
Registered User
Posts: 5
Joined: Tue Jan 20, 2009 8:15 pm

Re: Username and LDAP (Alternative Username)

Post by masterkeedu » Mon Jan 26, 2009 8:04 pm

Update**

in includes/function_content

DO NOT make the following edit as it will break the ability to pull users form a search in the admin panel because it will try to use the Real NAme rather than the username. Thus returning a "user Not Found" error.

Code: Select all

    if ($guest_username === false)
            {
            $sql = "SELECT * FROM `phpbb_users` WHERE `user_id` = '" . $user_id . "'";
            $result = $db->sql_query($sql);
            $row = $db->sql_fetchrow($result);
            $username = ($row['user_from']) ? $row['user_from'] : $username;
            $db->sql_freeresult($result);
            }
Instead copy the entire function, rename to get_realname_string() and insert back into the class using the code above in place of
$username = ($username) ? $username : $user->lang['GUEST'];
.

This way the internal workings can still retrieve the physical username when needed, and we can adjust all the outward facing displaying to use Real Name instead without disrupting other features.


To do this you'll need to start hacking away at
index.php, viewforum.php, and viewtopic.php, includes/functions_posting.php

Basically just do a global search on get_username_string(. Look where it is(the context of its use) and change to get_realname_string( as needed.

Example, we'll change the 'newest member' section of index.php that is shown at the foot on the index page

Starting ~ line 115 The NEWEST_USER is the line we care about.

Code: Select all

// Assign index specific vars
$template->assign_vars(array(
	'TOTAL_POSTS'	=> sprintf($user->lang[$l_total_post_s], $total_posts),
	'TOTAL_TOPICS'	=> sprintf($user->lang[$l_total_topic_s], $total_topics),
	'TOTAL_USERS'	=> sprintf($user->lang[$l_total_user_s], $total_users),
	'NEWEST_USER'	=> sprintf($user->lang['NEWEST_USER'], get_realname_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),

	'LEGEND'		=> $legend,

In all I probably had to replace this method call in about 20 places. But to ensure the integrity of the service i think it is worth it.

KhalsaKommander
Registered User
Posts: 2
Joined: Thu Nov 19, 2009 12:57 am

Re: Username and LDAP (Alternative Username)

Post by KhalsaKommander » Thu Nov 19, 2009 2:53 pm

My apologies as I'm a novice to both phpBB and php coding in general, but I've tried with no luck to implement the suggestions above.

What I can do is bind to my Active Directory LDAP, and have end users use their userid and password to login. However I cannot get their actual displayname in Active Directory to show as their name once logged in. In Active Directory, I can see that everyone has an item filled out via displayname (their actual first and last name).

When following Paul Manning's instructions above, I get an internal service error. My dB is MySQL and my web server is Apache. I have not reviewed my log files yet as to what the error may be.

When following masterkeedu, I get a MySQL error screen when logging in saying that "user form" cannot be blank.

So in short, has anyone gotten the above to work? If so, can you help me by providing specific instructions on how to go about implementing the above?

I don't think this should be too difficult to implement. Also has anyone gotten this to work by just using the ldap user filter in the client authentication section in the ADP? My team has got a Ruby on Rails application that can grab the displayname from LDAP and I want to implement the same for phpBB.

Thanks in advance for any kind thoughts that may be posted.

ddenise
Registered User
Posts: 1
Joined: Tue Jul 20, 2010 9:51 pm

Re: Username and LDAP (Alternative Username)

Post by ddenise » Tue Jul 20, 2010 10:03 pm

Hi, I want to do a slight variation to this thread here.

My Environment:
PHPBB3
LDAP integration to Active Directory

I'd like to:
1)Create a custom profile field called "Full Name"
2)Create a custom script that when authentication happens, pulls displayName from AD and populates the "Full Name" custom field with the displayName value from Active Directory.

I have done the following:
1) Created custom profile field (easy)
2) Created a custom script that will populate the custom profile field based on what username is logging in.

My strategy is to have this file separate and only add the following line to auth.php:

Code: Select all

	// BEGIN CUSTOM CODE HERE.
	// IF THE USER HAS SUCCESSFULLY LOGGED IN, THEN CALL THE CUSTOM FILE TO UPDATE DISPLAY NAME
	require(http://localhost/phpbb3/includes/auth/test.php);
	// END CUSTOM CODE.
When I add that line anywhere in auth.php, nothing works, I get just a blank screen. To confirm, yes, when I run the "test.php" it works just great. I also tried just including/requiring a blank .php file and it causes the same problem. Is there something I'm missing about how the php works with PHPBB3?

jdav
Registered User
Posts: 1
Joined: Tue Aug 02, 2011 8:50 pm

Re: Username and LDAP (Alternative Username)

Post by jdav » Tue Aug 02, 2011 9:10 pm

Dear Masterkeedu,

Thank you very much (and to Paul_manning22) for so good instruction how to get users' Full name from AD to PHPBB.

Everything is working after careful changes on version 3.0.8.

Only one thing is not working after all changes is access to the Client Communication /Authentication (LDAP settings) in the ACP.

After clicking to Authentication receiving "HTTP 500 Internal Server Error", all other tabs is accessible.

Please, help me to resolve this issue.

Stormy2021
Registered User
Posts: 7
Joined: Wed Apr 09, 2014 7:44 pm

Re: Username and LDAP (Alternative Username)

Post by Stormy2021 » Tue Apr 29, 2014 9:23 pm

Was a proper mod ever written for this? I cant seem to find one for 3.0.12.

MY board is LDAP authenticated. I would really like to have usernames, throughout the entire forum, replaced with Display Names.

In trying to go through the example code in this thread, it appears to be drastically different from the current 3.0.12 code, so I'm pretty much stuck.

* removed *
Last edited by marian0810 on Wed Apr 30, 2014 1:25 pm, edited 1 time in total.
Reason: solicitation removed as per https://www.phpbb.com/rules/#spam

JustAskJack
Registered User
Posts: 1
Joined: Thu Aug 27, 2015 3:12 pm

Re: Username and LDAP (Alternative Username)

Post by JustAskJack » Thu Aug 27, 2015 3:18 pm

Was there ever any movement or resolution on this?

I am facing the same issue using 3.1.5 and authenticating with LDAP.

Users log in with their company ID, but we would like for their name to be displayed when they post etc, right now it is displaying their company ID which makes it difficult to determine who is posting.

The steps covered earlier in the thread do not work for the newer versions of phpbb.

Let me know if you can point me in the right direction.

Thank you

Locked

Return to “[3.0.x] MOD Requests”

Who is online

Users browsing this forum: No registered users and 13 guests