how do I auto import all users from ldap?

Backend functionalities: user management, course management, reports, certificates, etc.
User avatar
murat
FormaLms User
Posts: 112
Joined: Fri Oct 12, 2012 6:28 pm
Version: forma.lms 2.0

how do I auto import all users from ldap?

Post by murat »

hi, I want to import all user into lms from ldap.
How do I this process ?
Do you know?
Hello,I'm Murat. If you need me, you can contact my mail

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 »

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: 490
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 »

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 User
Posts: 112
Joined: Fri Oct 12, 2012 6:28 pm
Version: forma.lms 2.0

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

Post by murat »

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?
Hello,I'm Murat. If you need me, you can contact my mail

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 »

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: 490
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 »

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 »

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: 490
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 »

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 »

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

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

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

Post by alberto »

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

Support the project for FREE!
www.Elearnit.net

Post Reply