Recent Topics

1 Aug 10, 2005 19:44    

Hello. I know I asked another question about login in another thread but this one is different and the other thread is getting confusing, even for me.

I'd simply like to know how I could make the login script so that users arent allowed to type in an username and password ... instead, I'd like to affect a default password for everyone (example: I'd like to simulate the fact that everyone would type "fakepwd" as a password without giving them a chance to type a password)

If you are wondering why I want to do that, it's simply to be able to allow automatic authentication. By setting "fakepwd" as if it had been typed by any user (even tho he didnt type anything) I then can set the username to be equal to $_SERVER["AUTH_USER"] automatically without requiring the user to type any username/password.

This way, all the user will have to do is push the "Log in!" button and he's gonna login under the right account.

I'd be very grateful if someone could answer that, tried figuring this out by myself but Im not used to PHP and I havent played enough in b2evolution's source code to have sufficient knowledge of it. It can't be as complicated as I see it (I made a few tests to try and find it, to no avail.)

2 Aug 10, 2005 20:19

Ok nevermind I found it.

In the htsrv/_login_form.php file, find this bit of code



<fieldset>
	<div class="label"><label for="pwd"><?php echo T_('Password:') ?></label></div>
	<div class="input"><input type="password" name="pwd" id="pwd" size="16" maxlength="20" value="" class="large" /></div>
</fieldset>

And replace the value of the input field by whatever you want as a default password, like this:



<fieldset>
	<div class="label"><label for="pwd"><?php echo T_('Password:') ?></label></div>
	<div class="input"><input type="password" name="pwd" id="pwd" size="16" maxlength="20" value="fakepwd" class="large" /></div>
</fieldset>

Now all I have to do is find a way to fetch the client's NTLM username with PHP (which I think is impossible ... well I hope not)

MODERATORS: You can delete this thread if you think it irrevelant, but this can always be useful to someone in the futur.

3 Aug 10, 2005 20:30

Instead of changing things on the login page like that (which can be easily overridden by users since it's available on the client-side) you should probably modify the actual login process on the server-side.

The function to log users in is defined in b2evocore/_functions_users.php. You can modify this function to check for the NTLM username (it should be available as an environment variable if you are using IIS) and automatically log the user in without even bothering with a password.

This way, there would be no need for a "default password", and the user would not have the ability to enter another user's ID.

4 Aug 10, 2005 21:43

I'll seriously check it out.

Thanks for the pointers Kweb !

5 Aug 10, 2005 22:19

I think I will need some help :oops:

I know I can get the NTLM username using the $_SERVER["REMOTE_USER"] variable.

I need pointers as to which funtion(s) I should change in the b2evocore/_functions_user.php file.

Also, I guess I can comment out all the code that hashes and validates the passwords ... then I simply compare the value of the "REMOTE_USER" environment variable with usernames in the databases and if everything fits it's ok ?

I'm checking the _functions_user.php file's code and I'm unsure of what to do and where ... normally I'd take time to analyse the code in details but I'm very short on time so I don't have the luxury to really get to know how the code works.

Sorry if I'm asking much, I wish I could take my time to implement all this :-/

6 Aug 10, 2005 22:45

I believe the function you need to modify is the veriflog() function (near the top).

I've never done this myself, so I can't really tell you exactly what to do. The code is well commented, though (kudos to the devs, by the way), so it shouldn't be hard to see where it's getting the login info and setting up the cookie. Just modify it to get the username from the variable and set the cookie that way. It may take some trial and error, so make sure you back up the file first!

7 Aug 11, 2005 16:26

I'd like to know how to make login so that when an user clicks on the "Login" link on the weblog it does not direct him to the login page.

How to make it so identification is made inside the b2evocore/_functions_user.php file without redirection to the login form ?

Which functions should I modify to achieve that and what modifications should I do ? An example of code would be very welcome but I fear not many people ever looked into the login process so there must not be a lot of knowledge about it ??

Anyways, any pointers are welcome !


Form is loading...