Moodle 上的无密码身份验证

发布于 2024-11-09 09:53:50 字数 351 浏览 5 评论 0原文

实际上我正在尝试将我的系统与moodle集成。我需要一个应该像这样工作的功能:

  1. 登录我的系统(与moodle db中的用户名相同)
  2. 用户决定切换到moodle,因此他单击脚本链接(在moodle服务器上 - 两个系统都在其他服务器上),我从数据库中获取有关我想要登录的用户的所有数据(来自数据库的整行)...
  3. 因为密码已加密,所以我现在无法使用帖子参数重定向到登录表单,因为它不起作用。

有什么好的、简单的方法来实现这个目标吗?我有用户名和散列密码以及最终散列密码。

我使用的是moodle 1.9(系统要求)。

预先感谢您的任何帮助,

问候大卫

Actually I am trying to integrate my system with moodle. I need a functionality that supposed to work like that:

  1. Login into my system (same username as in moodle db)
  2. User decide to switch to moodle, so his clicking a link to script (on moodle server - both systems are on other servers), and I getting all data from database about user that I want to log in (whole row from database) ...
  3. Because password is encrypted, I can't redirect now to login form with post params, because it won't work.

Is there any good and easy way to achieve this goal? I have username and hashed and eventually hashed password.

I am using moodle 1.9 (system requirments).

Thanks in advance for any help,

Regards David

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

怪我鬧 2024-11-16 09:53:50

SSO 和 Moodle 1.9 需要注意的一些事项:

Some things to look at for SSO and Moodle 1.9:

剑心龙吟 2024-11-16 09:53:50

这是我所做的

1 - 我启用了(外部数据库)身份验证插件

2 - 在文件夹(my/moodle/ root/login/)

    <?php
    require('../config.php');
    $username =  $_GET['id'];// 's3265';
    $serverName = 'moodle' ;
    $connectionInfo = array( "UID"=>"mssqlUser","PWD"=>"********","Database"=>"external_Database");
//I am using MSSQL2008
        echo '<form action="' . $CFG->wwwroot . 
             '/login/index.php" method="post" name="login" id="form">';

    $conn = sqlsrv_connect( $serverName, $connectionInfo );

    if (!$conn)
       {die('Could not connect: ' . sqlsrv_error());}
    $result = sqlsrv_query($conn , "SELECT * FROM Users WHERE LoginID = '" . $username . "'");

    var_dump($conn, $result);
    while($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC))
    {
            echo  $row['FName'] . " " . $row['LName'] . ", please wait. . .";
        $password =  $row['LoginPassword'];
    }
    sqlsrv_close($conn);
?>
        <p><input type="hidden" name="username" value="<?php echo $username ?>">
                <p><input type="hidden" name="password" value="<?php echo $password ?>">

        <script language="JavaScript">
             function Validate(){document.login.submit();}

             Validate();
        </script>

</form>

3 - 假设您将 rhr 文件命名为 (test.php)
现在您的链接应该类似于 (http://your_domain/moodle/login/test.php?id=yourusername)
对我来说它有效,但是。 。 。我不关心安全问题。 。 。如果你这样做。 。 。你必须添加一些东西

Here is what I did

1 - I enabled the (External database) Authentication Plugin

2 - Create this php file in folder (my/moodle/root/login/)

    <?php
    require('../config.php');
    $username =  $_GET['id'];// 's3265';
    $serverName = 'moodle' ;
    $connectionInfo = array( "UID"=>"mssqlUser","PWD"=>"********","Database"=>"external_Database");
//I am using MSSQL2008
        echo '<form action="' . $CFG->wwwroot . 
             '/login/index.php" method="post" name="login" id="form">';

    $conn = sqlsrv_connect( $serverName, $connectionInfo );

    if (!$conn)
       {die('Could not connect: ' . sqlsrv_error());}
    $result = sqlsrv_query($conn , "SELECT * FROM Users WHERE LoginID = '" . $username . "'");

    var_dump($conn, $result);
    while($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC))
    {
            echo  $row['FName'] . " " . $row['LName'] . ", please wait. . .";
        $password =  $row['LoginPassword'];
    }
    sqlsrv_close($conn);
?>
        <p><input type="hidden" name="username" value="<?php echo $username ?>">
                <p><input type="hidden" name="password" value="<?php echo $password ?>">

        <script language="JavaScript">
             function Validate(){document.login.submit();}

             Validate();
        </script>

</form>

3 - assume you named the rhr file (test.php)
now your link should look like (http://your_domain/moodle/login/test.php?id=yourusername)
for me it is working , but . . . I am not concerned about security . . . if you do . . . you have to add something to this

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文