Moodle外部数据库认证与MSSQL从窗口会员功能


Moodle external DB authentication with MSSQL from windowsMembership function

我正在使用Moodle并将其与新开发的ASP集成。NET应用程序,使用会员功能.....我也尝试过MD5哈希,SHA-1哈希…当我尝试用文本作为密码格式时,它是有效的。感觉编码和解码有一些问题…帮助将不胜感激....

我有从成员表创建的用户名和密码,并创建了一个视图,并试图从我的moodle访问它…那里有用户名和密码行,我无法访问它

编辑:当我尝试调试这个时,我可以看到MSSQL中存储的密码与moodle在查询中发送的密码不同。

请帮帮我……

密码存储在MSSQL

uMg8WgxqP+mB3hzcwbeAPqHnty4=                                                                                                     danielmoses

在moodle

的外部数据库设置页面中将哈希配置为SHA-1时的日志
[16-Mar-2014 08:47:40 UTC] sqlsrv_configure: SQLSTATE = IMSSP
[16-Mar-2014 08:47:40 UTC] sqlsrv_configure: error code = -14
[16-Mar-2014 08:47:40 UTC] sqlsrv_configure: message = An invalid parameter was passed to sqlsrv_configure.
[16-Mar-2014 08:47:40 UTC] <hr>connecting... hostname: localhost params: array (
'Database' => 'kpadb',
'UID' => 'sa1',
'PWD' => 'password',
)
**[16-Mar-2014 08:47:40 UTC] <hr>running query: 'SELECT *
FROM MoodleAuthentication
WHERE UserName = ''danielmoses''
AND Password = ''58cb4e2f82599535955e97a110eee6f429cd666d'''<hr>input array: false<hr>result: NULL**
[16-Mar-2014 08:47:40 UTC] (before) ADODB_COUNTRECS: 1 _numOfRows: -1 _numOfFields: -1
[16-Mar-2014 08:47:40 UTC] (after) _numOfRows: -1 _numOfFields: 2
[16-Mar-2014 08:47:40 UTC] _fetch()
[16-Mar-2014 08:47:40 UTC] fetch mode: assoc
[16-Mar-2014 08:47:40 UTC] <hr>after _fetch, fields: <pre> backtrace: <pre align=left> &nbsp; &nbsp; &nbsp; &nbsp; <font face="Courier New,Courier">ADORecordset_mssqlnative._fetch()</font><font color=#808080 size=-1> % line 2989, file: <a href="file:/C:'inetpub'wwwroot'moodle'lib'adodb'adodb.inc.php">adodb.inc.php</a></font>
&nbsp; &nbsp; &nbsp; <font face="Courier New,Courier">ADORecordSet.Init()</font><font color=#808080 size=-1> % line 1086, file: <a href="file:/C:'inetpub'wwwroot'moodle'lib'adodb'adodb.inc.php">adodb.inc.php</a></font>
&nbsp; &nbsp; <font face="Courier New,Courier">ADOConnection._Execute(SELECT * FROM MoodleAuthentication WHERE UserName = '..., false)</font><font color=#808080 size=-1> % line 1044, file: <a href="file:/C:'inetpub'wwwroot'moodle'lib'adodb'adodb.inc.php">adodb.inc.php</a></font>
&nbsp; <font face="Courier New,Courier">ADOConnection.Execute(SELECT * FROM MoodleAuthentication WHERE UserName = '...)</font><font color=#808080 size=-1> % line 117, file: <a href="file:/C:'inetpub'wwwroot'moodle'auth'db'auth.php">auth.php</a></font>
<font face="Courier New,Courier">auth_plugin_db.user_login(danielmoses, Dan@1234)</font><font color=#808080 size=-1> % line 4393, file: <a href="file:/C:'inetpub'wwwroot'moodle'lib'moodlelib.php">moodlelib.php</a></font>
<font face="Courier New,Courier">authenticate_user_login(danielmoses, Dan@1234)</font><font color=#808080 size=-1> % line 140, file: <a href="file:/C:'inetpub'wwwroot'moodle'login'index.php">index.php</a></font>
</pre>

在moodle

的外部db设置页面中将哈希配置为MD-5时的日志
[16-Mar-2014 08:56:37 UTC] sqlsrv_configure: SQLSTATE = IMSSP
[16-Mar-2014 08:56:37 UTC] sqlsrv_configure: error code = -14
[16-Mar-2014 08:56:37 UTC] sqlsrv_configure: message = An invalid parameter was passed to sqlsrv_configure.
[16-Mar-2014 08:56:37 UTC] <hr>connecting... hostname: localhost params: array (
'Database' => 'kpadb',
'UID' => 'sa1',
'PWD' => 'password',
)
**[16-Mar-2014 08:56:37 UTC] <hr>running query: 'SELECT *
FROM MoodleAuthentication
WHERE UserName = ''danielmoses''
AND Password = ''4518af96674e69424360f61f1f6d129c'''<hr>input array: false<hr>result: NULL**
[16-Mar-2014 08:56:37 UTC] (before) ADODB_COUNTRECS: 1 _numOfRows: -1 _numOfFields: -1
[16-Mar-2014 08:56:37 UTC] (after) _numOfRows: -1 _numOfFields: 2
[16-Mar-2014 08:56:37 UTC] _fetch()
[16-Mar-2014 08:56:37 UTC] fetch mode: assoc
[16-Mar-2014 08:56:37 UTC] <hr>after _fetch, fields: <pre> backtrace: <pre align=left> &nbsp; &nbsp; &nbsp; &nbsp; <font face="Courier New,Courier">ADORecordset_mssqlnative._fetch()</font><font color=#808080 size=-1> % line 2989, file: <a href="file:/C:'inetpub'wwwroot'moodle'lib'adodb'adodb.inc.php">adodb.inc.php</a></font>
&nbsp; &nbsp; &nbsp; <font face="Courier New,Courier">ADORecordSet.Init()</font><font color=#808080 size=-1> % line 1086, file: <a href="file:/C:'inetpub'wwwroot'moodle'lib'adodb'adodb.inc.php">adodb.inc.php</a></font>
&nbsp; &nbsp; <font face="Courier New,Courier">ADOConnection._Execute(SELECT * FROM MoodleAuthentication WHERE UserName = '..., false)</font><font color=#808080 size=-1> % line 1044, file: <a href="file:/C:'inetpub'wwwroot'moodle'lib'adodb'adodb.inc.php">adodb.inc.php</a></font>
&nbsp; <font face="Courier New,Courier">ADOConnection.Execute(SELECT * FROM MoodleAuthentication WHERE UserName = '...)</font><font color=#808080 size=-1> % line 117, file: <a href="file:/C:'inetpub'wwwroot'moodle'auth'db'auth.php">auth.php</a></font>
<font face="Courier New,Courier">auth_plugin_db.user_login(danielmoses, Dan@1234)</font><font color=#808080 size=-1> % line 4393, file: <a href="file:/C:'inetpub'wwwroot'moodle'lib'moodlelib.php">moodlelib.php</a></font>
<font face="Courier New,Courier">authenticate_user_login(danielmoses, Dan@1234)</font><font color=#808080 size=-1> % line 140, file: <a href="file:/C:'inetpub'wwwroot'moodle'login'index.php">index.php</a></font>
</pre>

这可能是密码盐

http://docs.moodle.org/25/en/Password_salting

尽管我建议使用外部数据库身份验证从asp.net系统同步您的用户

http://docs.moodle.org/26/en/External_database_authentication

这是一个古老的问题,但对于任何偶然发现它的人来说,这是一个工作的PHP代码,用于获取存储在密码哈希字段中的值:

$storedHash = base64_encode( sha1(base64_decode($passwordsalt) . mb_convert_encoding($password, 'UTF-16LE', 'UTF-8'), true) )

$password为未加密密码。

$passwordsalt为aspnet_Membership PasswordSalt字段。

$storedHash需要匹配存储在aspnet_Membership Password字段中的值