Nasten Posted May 5, 2020 Share Posted May 5, 2020 Hi, iam pretty new and have made a forum style page for intern project display. ATM i use a standard php loginscript, just so i can add the author of the text. But as you can imagine thats pretty inconvinient. Is their a way to get the username from my roaming profil or from the current AD user (dont need to auth, just so i can add my nameunder post, like i login on windows with username "Heinz", and write a post on my side, so he can take the username "Heinz" and display it beneth the post? iam pretty clueless where to start looking, would you be so nice and provide me some topic/hints to give me a push in the right direction. Sry if my english is..... a bit rubbish. i greatfull for all your time sincerly Nasten Quote Link to comment https://forums.phpfreaks.com/topic/310704-display-username-from-ad/ Share on other sites More sharing options...
StevenOliver Posted May 5, 2020 Share Posted May 5, 2020 No problem. A perfect place to start is by learning a bit more what PHP is about (browse this). Then this should help you with your question:https://www.php.net/manual/en/reserved.variables.post.php Quote Link to comment https://forums.phpfreaks.com/topic/310704-display-username-from-ad/#findComment-1577575 Share on other sites More sharing options...
Barand Posted May 5, 2020 Share Posted May 5, 2020 This class is excellent for working with AD Quote Link to comment https://forums.phpfreaks.com/topic/310704-display-username-from-ad/#findComment-1577577 Share on other sites More sharing options...
requinix Posted May 5, 2020 Share Posted May 5, 2020 If you're talking about it getting the user currently browsing the site, also look into what it takes to set up Kerberos authentication on your web server. Because that's not something PHP can handle for you - at least not without help. Quote Link to comment https://forums.phpfreaks.com/topic/310704-display-username-from-ad/#findComment-1577588 Share on other sites More sharing options...
Nasten Posted May 5, 2020 Author Share Posted May 5, 2020 Yeah i just want to get the Name off the current active user account which is signed in. I only got the computer name so far, but that's not what iam aiming for. I will look into your advice these days thanks, to you both. Quote Link to comment https://forums.phpfreaks.com/topic/310704-display-username-from-ad/#findComment-1577590 Share on other sites More sharing options...
gizmola Posted May 7, 2020 Share Posted May 7, 2020 Yes, you can make LDAP calls in php, to your AD. That would likely be the way I would do it from what little you've said. AD is compliant with LDAP. Quote Link to comment https://forums.phpfreaks.com/topic/310704-display-username-from-ad/#findComment-1577627 Share on other sites More sharing options...
Nasten Posted May 8, 2020 Author Share Posted May 8, 2020 (edited) edit: empty sry mobile phone made problems Edited May 8, 2020 by Nasten Quote Link to comment https://forums.phpfreaks.com/topic/310704-display-username-from-ad/#findComment-1577701 Share on other sites More sharing options...
Nasten Posted May 8, 2020 Author Share Posted May 8, 2020 On 5/7/2020 at 7:24 AM, gizmola said: Yes, you can make LDAP calls in php, to your AD. That would likely be the way I would do it from what little you've said. AD is compliant with LDAP. I did try some diffrent things with php, : <?php $username = getenv('USERNAME') ;//?: getenv('USER'); echo $username."<br />"; print shell_exec( '%username%' )."<br />"; $test= get_current_user(); echo $test; ?> first will just print out the Computer name, second prints "System". Quote Link to comment https://forums.phpfreaks.com/topic/310704-display-username-from-ad/#findComment-1577702 Share on other sites More sharing options...
gizmola Posted May 8, 2020 Share Posted May 8, 2020 I'm not sure what you are after there. Those are simply environment variables from the server running php. What is your server stack? Are you running IIS, Apache? What is the OS of the server? You stated that you have a simple login. What I've done in the past, is to have the login make LDAP calls to active directory to authenticate the user. Before you go down the LDAP road, If you are lucky and your environment intrinsically supports this, you could try to echo this value: echo "Current User is {$_SERVER['AUTH_USER']}"; Quote Link to comment https://forums.phpfreaks.com/topic/310704-display-username-from-ad/#findComment-1577706 Share on other sites More sharing options...
Nasten Posted May 8, 2020 Author Share Posted May 8, 2020 1 hour ago, gizmola said: I'm not sure what you are after there. Those are simply environment variables from the server running php. What is your server stack? Are you running IIS, Apache? What is the OS of the server? You stated that you have a simple login. What I've done in the past, is to have the login make LDAP calls to active directory to authenticate the user. Before you go down the LDAP road, If you are lucky and your environment intrinsically supports this, you could try to echo this value: echo "Current User is {$_SERVER['AUTH_USER']}"; Server is win2016, i run apache with xampp. IIS (?). The command did not work :/. I do not even like a new authentification with ldap, i just would like to display the name od the current active user account. Quote Link to comment https://forums.phpfreaks.com/topic/310704-display-username-from-ad/#findComment-1577708 Share on other sites More sharing options...
Nasten Posted May 8, 2020 Author Share Posted May 8, 2020 Thank for your help, exec command works fine, if i use a roaming profile. i hope you all stay well. Quote Link to comment https://forums.phpfreaks.com/topic/310704-display-username-from-ad/#findComment-1577709 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.