how do I auto import all users from ldap?

Questions about the backend functionalities: configuration, user management, course management, ...
User avatar
murat
FormaLms Expert
Posts: 104
Joined: Fri Oct 12, 2012 6:28 pm
Version: forma.lms 1.4

how do I auto import all users from ldap?

Post by murat » Mon Jan 15, 2018 11:29 pm

hi, I want to import all user into lms from ldap.
How do I this process ?
Do you know?

barlasd
Newbie
Posts: 10
Joined: Wed Jan 24, 2018 8:53 am

Re: how do I auto import all users from ldap?

Post by barlasd » Wed Jan 24, 2018 4:17 pm

I wrote a workaround that automatically adds the user to the database users, after the login (obviously after verifying that the LDAP accepts the login).

If you are interested i can share the code.

User avatar
canelli
FormaLms Guru
Posts: 465
Joined: Thu Nov 08, 2012 12:21 pm
Version: forma.lms 2.0
Contact:

Re: how do I auto import all users from ldap?

Post by canelli » Wed Jan 24, 2018 4:25 pm

very interesting feature

can you share the code ? we will integrate in forma.lms 2.0

claudio
Cercate nel forum le riposte prima di chiedere. Check the forum before posting
---------------
Claudio Anelli
Joint Technologies - Sistemi avanzati per l'information technology

http://www.joint-tech.com
---------------

User avatar
murat
FormaLms Expert
Posts: 104
Joined: Fri Oct 12, 2012 6:28 pm
Version: forma.lms 1.4

Re: how do I auto import all users from ldap?

Post by murat » Thu Jan 25, 2018 12:24 am

barlasd wrote:I wrote a workaround that automatically adds the user to the database users, after the login (obviously after verifying that the LDAP accepts the login).

If you are interested i can share the code.

please , can you share your codes?

barlasd
Newbie
Posts: 10
Joined: Wed Jan 24, 2018 8:53 am

Re: how do I auto import all users from ldap?

Post by barlasd » Thu Jan 25, 2018 10:15 am

Edit the file lib.user.php into the folder lib:

Replace the rows 231-235 with this code:

Code: Select all

if( $user_info === false ){
			
			if(Get::sett('ldap_used') == 'on') {
				
				$ldap_conn = @ldap_connect( Get::sett('ldap_server'), Get::sett('ldap_port', '389'));
				$ldap_user = ereg_replace( '\$user', $login, Get::sett('ldap_user_string') );
				if(ldap_bind($ldap_conn, $ldap_user, $password))
				{
					ldap_close($ldap_conn);
					$logldap = "/".$login;
					list($userid) = sql_fetch_row(sql_query("SELECT userid FROM core_user WHERE userid='$logldap'"));
					if($userid == ""){
						$date = date("Y-m-d H:i:s");
						list($idstMember) = sql_fetch_row(sql_query("SELECT max(idst)+1 FROM core_st"));
						sql_query("INSERT INTO core_user (idst, userid, valid, register_date) VALUES ($idstMember,'$logldap',1,'$date')");
						sql_query("INSERT INTO core_st (idst) VALUES ('$idstMember')"); 
						sql_query("INSERT INTO core_group_members (idst, idstMember) VALUES (1,'$idstMember')"); 
					}
				}
				else{
					  return $ret_value;
				}
			}	
			else{
				return $ret_value;
			} 
		}
    
		if( $user_info[ACL_INFO_VALID] != '1' && Get::sett('ldap_used') == 'off'){
			  return $ret_value;
		}
enjoy ;)

User avatar
canelli
FormaLms Guru
Posts: 465
Joined: Thu Nov 08, 2012 12:21 pm
Version: forma.lms 2.0
Contact:

Re: how do I auto import all users from ldap?

Post by canelli » Thu Jan 25, 2018 11:28 am

Thank for sharing your work.

We will integrate this in forma.lms 2.x .
I hope in the 2.0, but we are in the final beta status and soon we will enter in the Release canditate status, so I'm not sure that we can made the change. For sure te code will be integrated in the 2.1

Claudio
Cercate nel forum le riposte prima di chiedere. Check the forum before posting
---------------
Claudio Anelli
Joint Technologies - Sistemi avanzati per l'information technology

http://www.joint-tech.com
---------------

barlasd
Newbie
Posts: 10
Joined: Wed Jan 24, 2018 8:53 am

Re: how do I auto import all users from ldap?

Post by barlasd » Thu Jan 25, 2018 11:33 am

Hi Claudio,
Is there a way to access to betatesting of the Forma 2.0 version?
I'm curious to see the new features.

Grazie. :)

User avatar
canelli
FormaLms Guru
Posts: 465
Joined: Thu Nov 08, 2012 12:21 pm
Version: forma.lms 2.0
Contact:

Re: how do I auto import all users from ldap?

Post by canelli » Thu Jan 25, 2018 12:01 pm

hi barlasd .
to access beta you must enter in the "Contribution program".
you must fille the form available at www.formalms.org
Cercate nel forum le riposte prima di chiedere. Check the forum before posting
---------------
Claudio Anelli
Joint Technologies - Sistemi avanzati per l'information technology

http://www.joint-tech.com
---------------

barlasd
Newbie
Posts: 10
Joined: Wed Jan 24, 2018 8:53 am

Re: how do I auto import all users from ldap?

Post by barlasd » Thu Jan 25, 2018 12:19 pm

I had tried but i can't see the captcha...
Attachments
Cattura.PNG
Cattura.PNG (1.08 KiB) Viewed 89 times

User avatar
alberto
FormaLms Guru
Posts: 859
Joined: Fri Mar 02, 2012 9:18 am
Contact:

Re: how do I auto import all users from ldap?

Post by alberto » Thu Feb 01, 2018 11:39 am

Captcha fixed, thanks for noticing it
--------------------------------------------------
Become a CONTRIBUTOR

Support the project for FREE!
www.Elearnit.net

Post Reply