Solved

Detect windows user in php

Posted on 2007-11-19
9
2,189 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
ID: 20313789
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
ID: 20313971
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
ID: 20316392
is php installed on the intranet server as an isapi module or cgi binary?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 2

Author Comment

by:ChoobsTech
ID: 20317256
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
 
LVL 19

Assisted Solution

by:v2Media
v2Media earned 150 total points
ID: 20317539
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
ID: 20318912
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
ID: 20347015
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
ID: 20388800
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
ID: 20388810
Thanks ChoobsTech :)
0

Featured Post

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
What's wrong with this PDO query? 5 28
Read a remote csv file from a https URL 8 49
AJAX pass along a variable 3 46
Custom Wordpress Loop 22 39
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

828 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