1
Mestophales
Bypassing the Login

I am using XOOPS as an intranet for my department and instead of logging in I would like for it to read the NT Login. Does anyone know how to do this?

2
Mestophales
Re: Bypassing the Login

OK, I am an ASP programmer converting to the PHP side, and since I didn't get a response, I thought I would share my workaround. I am using this XOOPS as a departmental intranet on a win2k3 server. I first created a default.asp page that reads your NT Login to check against the SQL 2000 DB server to see if you belong in this department if so I pass along a username and general password, if not I send you on to the basic XOOPS start up page that will require them to register in order to login.

<%
Dim IIS_USER
Dim CurrentTime
IIS_USER 
request.servervariables("LOGON_USER")
Session("IIS_USER")= IIS_USER
LN 
Request.ServerVariables("REMOTE_USER")  
UserName LCase(Right(LNLen(LN) - InStr(1LN"")))

  
set rs=Server.CreateObject("adodb.Recordset")  
  
connectme="driver={SQL Server};SERVER=MyServer;DATABASE=MyDatabase_Name;UID=MyUser_ID;PWD=MyPassword;"
  
sqlstmt "SELECT * FROM Department_Employees WHERE UserName='" UserName "'"
  
rs.open sqlstmtconnectme
  
if rs.eof then
      call pass_on
  
else
%>
<
body onLoad="MyForm1.submit()">

<
form method="POST" action="http://MyDomain/xoops/html/user.php" name="MyForm1">
  <
p><input type="text" name="uname" size="20" value="<%=UserName%>"></p>
  <
p><input type="password" name="pass" size="20" value="<%=12345%>"></p>
  <
input type="hidden" name="xoops_redirect" 
  
value="/xoops/html/modules/news/index.php" /><input type="hidden" name="op" 
  
value="login" />
  <
p><input type="submit" value="User Login" /> </p>
</
form>
<%
end if
function 
pass_on()
response.redirect "http://MyDomain/xoops/html"
end function
%>


So in essence what happens is when the users navigate tohttp://MyDomain which is our local intranet the get redirected to where I want them to go based on if they are part of my department or not.

Again I thought this might be useful to someone else in the future. If you can think of a better way to do this, Please let me know.

3
Mithrandir
Re: Bypassing the Login

Could you try this out, please (I've not tested anything of this, I just found it on phpbuilder.com)
<?php
$username 
xoops_getenv('USERNAME');
$user_rslt $GLOBALS['xoopsDB']->query('SELECT uname, pass FROM '.$GLOBALS['xoopsDB']->prefix('users').' WHERE uname="'.$username.'"';
list(
$uname$pass) = $GLOBALS['xoopsDB']->fetchRow($user_rslt);
?>
<body onLoad="MyForm1.submit()">

<form method="POST" action="http://MyDomain/xoops/html/user.php" name="MyForm1">
  <p><input type="text" name="uname" size="20" value="<?php echo $uname?>"></p>
  <p><input type="password" name="pass" size="20" value="<?php echo $pass?>"></p>
  <input type="hidden" name="xoops_redirect" 
  value="/xoops/html/modules/news/index.php" /><input type="hidden" name="op" 
  value="login" />
  <p><input type="submit" value="User Login" /> </p>
</form>
<?
header
('location:http://MyDomain/xoops/html');
?>

4
Mestophales
Re: Bypassing the Login

This is the error I get

Parse error: parse error, unexpected ';' in d:\inetpub\wwwroot\xoops\html\default.php on line 12

5
Mithrandir
Re: Bypassing the Login

bleh - I really shouldn't be allowed to write code outside Zend

$user_rslt $GLOBALS['xoopsDB']->query('SELECT uname, pass FROM '.$GLOBALS['xoopsDB']->prefix('users').' WHERE uname="'.$username.'"');

I forgot the closing bracket

6
Mestophales
Re: Bypassing the Login

This is the new error

Fatal error: Call to undefined function: xoops_getenv() in d:\inetpub\wwwroot\xoops\html\default.php on line 11

7
Mithrandir
Re: Bypassing the Login

/me hits himself.

add
include "../../mainfile.php";

as the first PHP line (or include "mainfile.php") if this script is running in the XOOPS root)

8
Mestophales
Re: Bypassing the Login

That actually did not produce any errors - however it did not pass along any login information.

9
Mithrandir
Re: Bypassing the Login

what if you try to echo the $username variable? or disable the redirection and "view source"?

Alternatively, slap a
include XOOPS_ROOT_PATH."/header.php";
include 
XOOPS_ROOT_PATH."/footer.php";

at the very bottom (just before the last ?> tag) and enable MySQL Debug and see if the SQL query to lookup the user in the XOOPS database is working properly (you'll need to disable/comment out the redirection for this, too).

10
Mestophales
Re: Bypassing the Login

I have determined it is not retrieving the NT Username from the server variables. I have edited the security settings on the server so that the information will pass. In ASP no problem, I am finding PHP is a little more finicky.

Login

Who's Online

132 user(s) are online (105 user(s) are browsing Support Forums)


Members: 0


Guests: 132


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits