tri_94 Posted June 28, 2011 Posted June 28, 2011 I need a simple php script to display the logged on users username on our vle. Can anyone help? Thanks
Marci Posted June 28, 2011 Posted June 28, 2011 (edited) Not without knowing specifically which VLE you're using... but generally, find out the variable that holds the username, and echo it... eg: For Moodle1/2 echo $USER->username; Edited June 28, 2011 by Marci
vikpaw Posted June 28, 2011 Posted June 28, 2011 I'm no PHP expert so this code might depend on your setup, but i do it like this: <?php echo $_SERVER['LOGON_USER']; ?>
Marci Posted June 28, 2011 Posted June 28, 2011 That one should only work for VLEs running ntlm authentication via mod_ntlm or similar... like I said, it's specific to the VLE and how it's hosted as to how you can access it's variables. Without more detailed info, we're all just plucking feathers from our asses.
tri_94 Posted June 28, 2011 Author Posted June 28, 2011 That one should only work for VLEs running ntlm authentication via mod_ntlm or similar... like I said, it's specific to the VLE and how it's hosted as to how you can access it's variables. Without more detailed info, we're all just plucking feathers from our asses. hi there all i get is echo $USER->username; displaying in ie.
Marci Posted June 28, 2011 Posted June 28, 2011 Not without knowing specifically which VLE you're using... like I said, it's specific to the VLE and how it's hosted as to how you can access it's variables. Without more detailed info, we're all just plucking feathers from our asses. Which VLE are you using?
Marci Posted June 28, 2011 Posted June 28, 2011 Moodle 1.9 should display logged in user in top right corner of every page by default. In which moodle file are you inserting the code?
tri_94 Posted June 28, 2011 Author Posted June 28, 2011 we are trying to get SSO working on moodle 1.9, and it seems to be failing, we are trying to test that ie is pulling the username from the machine correctly so that we can elminate that as the issuse.
Marci Posted June 28, 2011 Posted June 28, 2011 (edited) In which moodle file are you inserting the code? As per my above post... but if SSO is failing, there wont' be a "logged in user" for Moodle to display, as the user hasn't logged in, cos it's failed, so it won't display anything inside Moodle. SSO is NTLM, so therefore vikpaw's code above should work. Put echo $_SERVER['LOGON_USER']; ?> in a file called test.php, upload it to somewhere on your website, visit it in a browser. If NTLM is picking up the user correctly it'll display the username on screen, which means it's failing because your Moodle config is incorrect. If however it DOESN'T display a name on screen, NTLM isn't working correctly and your web browser isn't able to retrieve the username from Windows. Edited June 28, 2011 by Marci
tri_94 Posted June 28, 2011 Author Posted June 28, 2011 We were just trying to test it. with the php script
Marci Posted June 28, 2011 Posted June 28, 2011 Which is what the instructions in my post above are telling you how to do: SSO is NTLM, so therefore vikpaw's code above should work. Put echo $_SERVER['LOGON_USER']; ?> in a file called test.php, upload it to somewhere on your website, visit it in a browser. If NTLM is picking up the user correctly it'll display the username on screen, which means it's failing because your Moodle config is incorrect. If however it DOESN'T display a name on screen, NTLM isn't working correctly and your web browser isn't able to retrieve the username from Windows.
tri_94 Posted June 28, 2011 Author Posted June 28, 2011 hi there just tried that and i get a blank page in ie
Marci Posted June 28, 2011 Posted June 28, 2011 Your webserver isn't able to get the username from windows. Work your way thru NTLM authentication - MoodleDocs step by step following whichever section is relevant to your setup (ie: depends what ver of IIS your using, or what ver of Apache you're using).
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now