Jump to content

display username from ad


Nasten

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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".

Link to comment
Share on other sites

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']}";

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.