简体   繁体   English

moodle 3.1版与amember集成

[英]moodle version 3.1 integration with amember

In our system we want to integrate moodle plugin(version 3.1) with amember.We have some users in moodle with passwords in encrypted format and we want to import those users to amember without changing users passwords using api. 在我们的系统中,我们希望将moodle插件(版本3.1)与amember集成在一起。我们让一些用户使用了加密格式的密码,并且希望将这些用户导入到amember中而不使用api更改用户密码。

Can anyone please suggest a way how can we handle this? 任何人都可以提出一种解决该问题的方法吗?

I am using following code to create users in amember.it successfully create users in amember but when i try to login it denied. 我正在使用以下代码在amember中创建用户。它成功在amember中创建用户,但是当我尝试登录时被拒绝。

$url = 'http://YOURDOMAIN.COM/amember/api/users';

$fields = array(
'_key' => 'SECRETKEY',
'_format' => 'xml',
'login' => 'USERNAME',
'pass' => 'PASSWORD',
'email' => 'EMAIL',
'name_f' => 'FIRST NAME',
'name_l' => 'LAST NAME',
);
 //open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
 curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: application/x-  www-form-urlencoded"));

//execute post
$result = curl_exec($ch);

//close connection
curl_close($ch);

Thanks in advance. 提前致谢。

Since the passwords in moodle are encrypted, you won't be able to decrypt the passwords. 由于moodle中的密码已加密,因此您将无法解密密码。 As I read your code, amember api will require a plain password when creating a user. 当我阅读您的代码时,创建用户时,member api将需要一个普通密码。

The only workaround I see would result in having an own authentification plugin in moodle. 我看到的唯一解决方法将导致在moodle中拥有自己的身份验证插件。 This plugin will be called once an existing moodle users tries to login. 现有的用户开始尝试登录时,将调用此插件。 You can then use the user_login method, to verify the password against moodle database. 然后,您可以使用user_login方法,以针对moodle数据库验证密码。 Furthermore in this stage you have the plaintext password, so you can create a new amember user, once login is successful 此外,在此阶段,您具有纯文本密码,因此,一旦登录成功,便可以创建一个新的成员用户。

You do not need to use API in order to import users. 您无需使用API​​即可导入用户。

aMember has admin tool that allow you to import users from CSV files. aMember具有管理工具,可让您从CSV文件导入用户。 This tool allow you to import user with encrypted/hashed passwords. 该工具允许您使用加密/散列密码导入用户。

aMember CP -> Users -> Import Users aMember CP->用户->导入用户

You can export user from your moodle database to CSV file. 您可以从用户数据库中将用户导出到CSV文件。

You need to enable moodle integration plugin within aMember before do such import. 在进行此类导入之前,您需要在aMember中启用moodle集成插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM