Reputation: 201
Actually I am trying to integrate my system with moodle. I need a functionality that supposed to work like that:
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
Upvotes: 1
Views: 4122
Reputation: 171
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
Upvotes: 0
Reputation: 383
Some things to look at for SSO and Moodle 1.9:
Upvotes: 1