Jump to content

LDAP (Active Directory) and login to php/MySQL based application help


AaronJAnderson

Recommended Posts

I am new to PHP. I have been trying to do some research online for a few days and not getting very far. I feel like I know less now than I did before I started.

 

Here's the story:

 

I've set up a LAMP server that runs a Wiki and AppGini (http://www.bigprof.com/appgini/) - AppGini allows you to "Create web database applications instantly without writing any code" - The only downside we have with it, is it's got it's own set of user accounts. My team all logs in with the default admin account which isn't a big deal but we'd prefer to use LDAP to AD for reasons I won't get into right now.

 

I emailed AppGini support and asked about LDAP integration. Their response was that it's "a little bit of work" and "You can modify the login authentication function to authenticate using LDAP ... please see the example code here: http://code.activestate.com/recipes/101525-ldap-authentication/ (needs some modifications to work with AppGini)"

 

I've googled around and found 2 dozen different LDAP PHP samples. I've gotten some of them to work. By work I mean they connect to my domain controller and say "success" I'm not actually logged into anything.

 

So I'm looking for a little help from square one. I need to have a better understanding of how things are supposed to work so I know where I'm supposed to go with all of this. Where do I start? What do I do? What would YOU do?

 

 

This is the current "index.php" that logs you into the site.

<?php

error_reporting(E_ALL ^ E_NOTICE);
$d=dirname(__FILE__);
include("$d/defaultLang.php");
include("$d/language.php");
include("$d/incCommon.php");
$x->TableTitle=$Translation['homepage'];
include("$d/header.php");

if($_GET['signOut']==1){
	logOutMember();
}

$tablesPerRow=2;
$arrTables=getTableList();

?>
<div align="center"><table cellpadding="8">
	<?php if($_GET['loginFailed']==1 || $_GET['signIn']==1){ ?>
	<tr><td colspan="2" align="center">
		<?php if($_GET['loginFailed']){ ?>
		<div class="Error"><?php echo $Translation['login failed']; ?></div>
		<?php } ?>
		<form method="post" action="index.php">
			<table border="0" cellspacing="1" cellpadding="4" align="center">
				<tr>
					<td colspan="2" class="TableHeader">
						<div class="TableTitle"><?php echo $Translation['sign in here']; ?></div>
						</td>
					</tr>
				<tr>
					<td align="right" class="TableHeader">
						<?php echo $Translation['username']; ?>
						</td>
					<td align="left" class="TableBody">
						<input type="text" name="username" value="" size="20" class="TextBox">
						</td>
					</tr>
				<tr>
					<td align="right" class="TableHeader">
						<?php echo $Translation['password']; ?>
						</td>
					<td align="left" class="TableBody">
						<input type="password" name="password" value="" size="20"class="TextBox">
						</td>
					</tr>
				<tr>
					<td colspan="2" align="right" class="TableHeader">
						<span style="margin: 0 20px;"><input type="checkbox" name="rememberMe" id="rememberMe" value="1"> <label for="rememberMe"><?php echo $Translation['remember me']; ?></label></span>
						<input type="submit" name="signIn" value="<?php echo $Translation['sign in']; ?>">
						</td>
					</tr>
				<tr>
					<td colspan="2" align="left" class="TableHeader">
						<?php echo $Translation['go to signup']; ?>
						<br /><br />
						</td>
					</tr>
				<tr>
					<td colspan="2" align="left" class="TableHeader">
						<?php echo $Translation['forgot password']; ?>
						<br /><br />
						</td>
					</tr>
				<tr>
					<td colspan="2" align="left" class="TableHeader">
						<?php echo $Translation['browse as guest']; ?>
						<br /><br />
						</td>
					</tr>
				</table>
			</form>
			<script>document.getElementsByName('username')[0].focus();</script>
		</td></tr>
	<?php } ?>
<?php
	if(!$_GET['signIn'] && !$_GET['loginFailed']){
		if(is_array($arrTables)){
			if(getLoggedAdmin()){
				?><tr><td colspan="<?php echo ($tablesPerRow*3-1); ?>" class="TableTitle" style="text-align: center;"><a href="admin/"><img src=table.gif border=0 align="top"></a> <a href="admin/" class="TableTitle" style="color: red;"><?php echo $Translation['admin area']; ?></a><br /><br /></td></tr><?php
			}
			$i=0;
			foreach($arrTables as $tn=>$tc){
				$tChk=array_search($tn, array());
				if($tChk!==false && $tChk!==null){
					$searchFirst='?Filter_x=1';
				}else{
					$searchFirst='';
				}
				if(!$i % $tablesPerRow){ echo '<tr>'; }
				?><td valign="top"><a href=<?php echo $tn; ?>_view.php<?php echo $searchFirst; ?>><img src=<?php echo $tc[2];?> border=0></a></td><td valign="top" align="left"><a href=<?php echo $tn; ?>_view.php<?php echo $searchFirst; ?> class="TableTitle"><?php echo $tc[0]; ?></a><br /><?php echo $tc[1]; ?></td><?php
				if($i % $tablesPerRow == ($tablesPerRow - 1)){ echo '</tr>'; }else{ echo '<td width="50"> </td>'; }
				$i++;
			}
		}else{
			?><tr><td><div class="Error"><?php echo $Translation['no table access']; ?><script language="javaScript">setInterval("window.location='index.php?signOut=1'", 2000);</script></div></td></tr><?php
		}
	}
?>

</table><br /><br /><div class="TableFooter"><b><a href=http://bigprof.com/appgini/>BigProf Software</a> - <?php echo $Translation['powered by']; ?> AppGini 4.61</b></div>

</div>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.