473,395 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

user name

i am going through the process of password protecting a directory using
..htaccess and .htpasswd
Is there a function to get the user name?

Thanks
Jul 17 '05 #1
8 2500
..htpasswd is a text file. The user name's in it are not encrypted. On
each line, you'll find a username, then a colon (:), and then the
encrypted password. Assuming you can read that file, you could run a
regular expression on it to parse out the usernames.

Why do you need them? Just curious. Generally, people either do their
authentication in PHP or via .htaccess. It seems you're trying to do
some combination of the two.

Jul 17 '05 #2

phpinfo();
||

$_SERVER['PHP_AUTH_USER']

$_SERVER['PHP_AUTH_PASS'] // not sure

--
Sat_
Jul 17 '05 #3
"mickeyg" <me**********@yahoo.com> wrote in message news:PkVdd.6818$Ug4.4058@trndny01...
i am going through the process of password protecting a directory using
.htaccess and .htpasswd
Is there a function to get the user name?


use the $_SERVER superglobal array:

$_['PHP_AUTH_USER']
When running under Apache as module doing HTTP authentication this variable is set to the username provided by the user.

$_['PHP_AUTH_PW']

When running under Apache as module doing HTTP authentication this variable is set to the password provided by the user.

http://us2.php.net/manual/en/reserve...riables.server

____________________________________
Wil Moore III, MCP | Integrations Specialist | Assistant Webmaster

Jul 17 '05 #4
mickeyg wrote:
i am going through the process of password protecting a directory using
.htaccess and .htpasswd
Is there a function to get the user name?


The $_SERVER superglobal array /may have/ the authentication elements:

<quote src="http://pt.php.net/manual/en/reserved.variables.php">
'PHP_AUTH_USER'
When running under Apache as module doing HTTP authentication
this variable is set to the username provided by the user.

'PHP_AUTH_PW'
When running under Apache as module doing HTTP authentication
this variable is set to the password provided by the user.

'AUTH_TYPE'
When running under Apache as module doing HTTP authenticated this
variable is set to the authentication type.
</quote>
--
USENET would be a better place if everybody read:
http://www.expita.com/nomime.html
http://www.netmeister.org/news/learn2quote2.html
http://www.catb.org/~esr/faqs/smart-questions.html
Jul 17 '05 #5
>.htpasswd is a text file. The user name's in it are not encrypted. On
each line, you'll find a username, then a colon (:), and then the
encrypted password. Assuming you can read that file, you could run a
regular expression on it to parse out the usernames.
I believe the OP wants the user name of the user accessing the page
this time, not all of them.

To further complicate things, there is no guarantee that the .htpasswd
file is in *THIS* directory.
Why do you need them? Just curious. Generally, people either do their
authentication in PHP or via .htaccess. It seems you're trying to do
some combination of the two.


It is perfectly reasonable to have a restricted-access page, and further
let the page use the user name of the person accessing it, for
various purposes:

- Logging who did what.
- Using preferences individual to each user.
- Granting privileges individual to each user (determined, say, from
looking in a database or even hardcoded into the script).

Sometimes it is convenient to let Apache do the authentication (browsers manage
to store authentication info so you can come back at any time without needing
sessions or other such stuff. If your security policy isn't worried about
logins with no timeouts or unattended computers, this is great.) and then
let PHP hand out individual privileges based on WHO logged in.

The authenticated user shows up in $_SERVER['REMOTE_USER'] from Apache.
PHP also puts the user in $_SERVER['PHP_AUTH_USER'] and the password
in $_SERVER['PHP_AUTH_PW'] .

Gordon L. Burditt
Jul 17 '05 #6
Thank you this is what I was looking for
Jul 17 '05 #7
Gordon,

Thanks for the info. I didn't know that the username and password
provided during the .htaccess authentication process were availible to
PHP through server variables. Thanks for explaining their use.

Jul 17 '05 #8
Gordon Burditt wrote:
.htpasswd is a text file. The user name's in it are not encrypted. On
each line, you'll find a username, then a colon (:), and then the
encrypted password. Assuming you can read that file, you could run a
regular expression on it to parse out the usernames.


I believe the OP wants the user name of the user accessing the page
this time, not all of them.

To further complicate things, there is no guarantee that the .htpasswd
file is in *THIS* directory.
Why do you need them? Just curious. Generally, people either do their
authentication in PHP or via .htaccess. It seems you're trying to do
some combination of the two.


It is perfectly reasonable to have a restricted-access page, and further
let the page use the user name of the person accessing it, for
various purposes:

- Logging who did what.
- Using preferences individual to each user.
- Granting privileges individual to each user (determined, say, from
looking in a database or even hardcoded into the script).

Sometimes it is convenient to let Apache do the authentication (browsers manage
to store authentication info so you can come back at any time without needing
sessions or other such stuff. If your security policy isn't worried about
logins with no timeouts or unattended computers, this is great.) and then
let PHP hand out individual privileges based on WHO logged in.

The authenticated user shows up in $_SERVER['REMOTE_USER'] from Apache.
PHP also puts the user in $_SERVER['PHP_AUTH_USER'] and the password
in $_SERVER['PHP_AUTH_PW'] .


I like to do this for the priveleges and logging you mentioned and also peace of
mind - I know that, if I ever accidentally overwrite the .htaccess and don't
notice, nobody will be able to wander on in and screw everything up.

Shawn

--
Shawn Wilson
sh***@glassgiant.com
http://www.glassgiant.com
Jul 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tom Loach | last post by:
Our system administrator set up an NT server group in order to allow our users to login to our application via https to our sql server. The group appears as a User in SQL Server when you look at...
2
by: Technical Group | last post by:
Friends, Can anybody help me out by sending a piece of C# code showing how to add an active directory user to a particular user group? If the group does not exist, then create it. Thanks in...
6
by: Andrew Chalk | last post by:
My application attempts to connect to an SQL Server database as name ASPNET and Login Name SERVERNAME/ASPNET in response to these commands: SqlConnection myConnection = new SqlConnection("Data...
1
by: tony | last post by:
Hello! I just want to find out how the system find the name to set on a assembly User control dll. I have done this. 1. Create a user control - Here the namespace was set by the system to...
3
by: Dmitry | last post by:
I am trying to figure out how to pass set of credentials to System.IO Challenge is: App is running under one set of credentials, but via GUI user have a chance to enter another set. I would like...
2
by: underground | last post by:
Hi, everyone I've been trying to figure out a way for a user to update there information. I'm using sections to identify the specific user..Here is the form <? include("include/session.php");...
3
by: Terry Olsen | last post by:
I'm trying to add a domain user to a local group using the code below: Dim LCL As New DirectoryEntry("WinNT://" + Environment.MachineName + ",computer") Dim DOM As New...
2
by: dgbergman | last post by:
I have created a php login page in my site for my company. The goal is to get people into members area. Below is a list of steps that I take to create my login page in Dreamweaver CS3, can some one...
0
by: rbukkara | last post by:
Hi, I have got the following error while trying to add a user in the LDAP Directory. javax.naming.NameNotFoundException: ; remaining name 'uid=vassila,ou=People,dc=cs,dc=uno,dc=edu' I have...
14
by: chromis | last post by:
Hi, I've been trying to implement a more OOP oriented approach to dealing with user security on one of my websites, and I am trying to validate the user against an array of roles, however I am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.