Solved

Detect windows user in php

Posted on 2007-11-19
9
2,185 Views
Last Modified: 2013-12-24
Dear experts,

I am designing an intranet application, and I would like to use the windows authentification on my intranet.

What are my options? Can I detect either the windows user or the current active directory user with php?

Thnx in advance :D
0
Comment
Question by:ChoobsTech
  • 4
  • 3
  • 2
9 Comments
 
LVL 2

Author Comment

by:ChoobsTech
Comment Utility
Please provide an explicit answer, as I have to admit I didn't fully understand following link:
http://de3.php.net/manual/en/features.http-auth.php
0
 
LVL 21

Expert Comment

by:nizsmo
Comment Utility
so basically you are wanting the user to enter a password and a username upon reaching for example your local domain address http://10.1.2.3?
0
 
LVL 19

Expert Comment

by:v2Media
Comment Utility
is php installed on the intranet server as an isapi module or cgi binary?
0
 
LVL 2

Author Comment

by:ChoobsTech
Comment Utility
To nizsmo:
Ideally I would like to grant access, onsite or remotly without asking users to enter credentials again, based on the username detection I would do...

To v2Media:
I don't know, I will check with my admin and get back to you.
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 19

Assisted Solution

by:v2Media
v2Media earned 150 total points
Comment Utility
As a quick solution, if using IIS you can eliminate anonymous access to the website and use integrated windows authentication. This is simply done by opening IIS Admin, right clicking the default web site for properties and selecting the directory security tab.

Under directory security there's anonymous access, disable it. Check the option for "Integrated Windows Authentication".

0
 
LVL 21

Accepted Solution

by:
nizsmo earned 350 total points
Comment Utility
I'm not too sure if this is what you are looking for, but it is a very simple PHP authentication script, and you have to specify the username and password at the top.

You can easily configure it for multiple users and passwords by using a password and username array.

As i said, not sure if this is what you are looking for but hope it helps.
<?php

// specify password & username

$username = "test";

$password = "testing";
 

if (!isset($_SERVER['PHP_AUTH_USER'])) 

{

    header('WWW-Authenticate: Basic realm="My Realm"');

    header('HTTP/1.0 401 Unauthorized');

    exit;

}
 

if($_SERVER['PHP_AUTH_USER'] != $username || $_SERVER['PHP_AUTH_PW'] != $password)

{

	header('WWW-Authenticate: Basic realm="My Realm"');

	header('HTTP/1.0 401 Unauthorized');

	exit;

}
 

// Your PHP CONTENTS HERE IF THEY ENTER CORRECT PASSWORD & USERNAME!

echo "Success!!";

?> 

Open in new window

0
 
LVL 2

Author Comment

by:ChoobsTech
Comment Utility
Question has not been forgotten... I'll do the test in the next 2-3 days and assign points if it works...
0
 
LVL 2

Author Comment

by:ChoobsTech
Comment Utility
Ok could not really test it as I opted for another solution. Still people that helped deserve points.

nizsmo   350 points (as answers were more precise)
v2Media 150 points
0
 
LVL 21

Expert Comment

by:nizsmo
Comment Utility
Thanks ChoobsTech :)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now