PHP - Ldap_bind Returns Error 49 Invalid Credentials
I am able to connect to my AD server successfully. This server serves multiple domains.
Example is user1@dom1.dom.net is able to successfully bind. user2@dom2.com is not able to bind but gets error 49: invalid credentials. Using windows ldp.exe, I can connect successfully, then select bind from the connection menu, enter the username (user2), the account password, and the Domain (dom2.com) and the result indicated is successful. Using php I attempt to bind using: $adBind = ldap_bind($ad, $adUname, $ldappass); Where $ad = successful connection resource, $adUname = user1@dom1.dom.com OR user2@dom2.com, $ldappass is the account password. As user1 it is successful, with user2 it is unable to bind with error 49. Any suggestions or help is greatly appreciated. Thanks in advance! Similar TutorialsI have a class (P3TElement) that extends the DOMElement class in PHP. In there i have a public variable "attributes" which is an array, and an method named add_attribute($attr), the argument is a different class (P3TAttribute). However I am getting an error when trying to use it. The exact error is: Warning: P3TElement::add_attribute() [p3telement.add-attribute]: Invalid State Error in D:\www\p3textract\extract.php on line 110 Please see the code: http://pastebin.com/CbsM9V5W This class is supposed to extract .p3t (ps3 themes) files, and is a direct port of the python equivalent found at http://p3textractor.googlecode.com/svn/trunk/p3textractor.py Could you please help me fix this? thanks in advance, Hosh Hello everyone! I'm working on a PHP employee database that uses the local network's active directory to allow users to log in. Basically, I'm using the ldap_bind command to authenticate and figure out what user is logging in. The main snippet of code is: Code: [Select] $username = $_POST['username']; $password = $_POST['password']; $convertedPassword = utf8_encode($password); if (ldap_bind($ds,"health1\\" . $username,$convertedPassword)){do stuff} This works fine for normal username/passwords, but has been getting hung up on special characters. I added the utf8_encode command, which allowed password with carrot (^) characters, but it still won't allow backslashes ( \ ). I get Code: [Select] Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server: Invalid credentials in /var/www/emp/index.php on line 22 every time with a password such as "Blabla12\" The utf8_encode command seems to be escaping the \, which I think is what I want. Has anybody else had any luck with this? -Sam Hi sorry for the trouble guys but i'm really stuck on this one, and i've tried everything i can. (I've been using php only for sometime now) I'm stuck at this code and can't figure out why this is failing. Objective of the script : To try and include BOTH files or throw and exception if even one fails. I tried : Including just one at a time. Its fine, so i know the path is correct. I tried a if (! (expr1 && expr2) ) statement to check if the syntax is correct to create a everything or nothing logic. $offlineLibraryPath = '/var/www/common/lib'; // Attempt to include the files try { if(! ( require_once($offlineLibraryPath.'/variables/all.php') && require_once($offlineLibraryPath.'/functions/all.php') ) ) { throw new Exception ('Including all the common library files failed.'); } } catch (Exception $e) { echo '<b>Error</b> :'.$e->getMessage(); } I get this error : Warning: require_once(1): failed to open stream: No such file or directory in /var/www/common/lib/startupIncludes.php on line 18 Fatal error: require_once(): Failed opening required '1' (include_path='/var/www/common/lib/: /var/www/culturesque/lib/: /var/www/mine/lib/') in /var/www/common/lib/startupIncludes.php on line 18 Thanks in advance for the help! friends if an array returns results as Array() how could i set an error message to it? i tried to do a if statement to the $variable but not working Hi I don't want errors on my page been reported on the web browser for all to see so I use this. $total2 = mysql_num_rows($qCheckUser) or die ("Error1"); however if the query returns zero rows I get Error1 on the web page. This is not an error and I don't want to taje out the or die() Any sugestions. httpd-2.2.17-win32-x86-openssl-0.9.8o php-5.3.6-Win32-VC9-x86 mysql-5.5.11-win32 PHP code: $dbcnx = mysql_connect('localhost','root','admin'); Error message: No connection could be made because the target machine actively refused it. I used mysql.exe -u root -p to verify that mysql is working and using the right username and password. Any ideas how to fix it? Thanks, Richard I have an facebook application, I look in the errors log routinely to see if there are any abnormalities. Today, I found one. Code: [Select] [Sun Feb 27 15:28:25 2011] [error] [client **.***.71.38] PHP Notice: Undefined offset: 0 in *** on line 33 [Sun Feb 27 15:28:26 2011] [error] [client **.***.71.38] Exception: 121: Param pid must be a valid merged photo id Now, I have no idea what is going on here. I have found the location of where the error occurs: Code: [Select] $fb_photo = $facebook->api("me/photos", "POST", $attachement); $FQLQuery = "SELECT object_id, pid, src_big, link FROM photo WHERE object_id = " . $fb_photo['id']; $FQLResult = $facebook->api(array('method' => 'fql.query', 'query' => $FQLQuery, 'access_token'=> $session['access_token'])); $targetPhoto = $FQLResult[0]; I tried to help a user of mine get their account back on track, however, re-authenticating the application seems like the only way to fix it. It works for most of the users, however, there are a couple few who get my exception message. If anyone has any knowledge of whats going on here, that would be appreciated I have a web service that queries an Oracle database and then returns a struct. If there is any error on my side, I still reply the struct, except it is populated with differnt values. If I change the coding in my error handling to return the struct populated with the error values, then it returns fine, but if I simulate an ORACLE error (use the incorrect passoword for example) I get the following error: "XML error parsing SOAP payload on line 2: Invalid document end" Any suggestions? Is there a way that I can display the "SOAP Payload" to see what is missing? The following extract from my code: <<<< <?php require_once('../NuSoap/lib/nusoap.php'); date_default_timezone_set('Africa/Johannesburg'); $server = new soap_server(); $server->configureWSDL('oracle_err', 'urn:oracle_err'); $server->wsdl->addComplexType('ReturnRecords', 'complexType', 'struct', 'all', '', array( 'FirstVal' =>array('name'=>'FirstVal' , 'type'=>'xsd:string'), 'SecondVal'=>array('name'=>'SecondVal', 'type'=>'xsd:string'), 'ThirdVal' =>array('name'=>'ThirdVal' , 'type'=>'xsd:string'), 'FourthVal'=>array('name'=>'FourthVal', 'type'=>'xsd:string'), 'FifthVal' =>array('name'=>'FifthVal' , 'type'=>'xsd:string'))); $server->wsdl->addComplexType('RecordStatus', 'complexType', 'struct', 'all', '', array( 'ErrStatus'=>array('name'=>'ErrStatus', 'type'=>'xsd:string'), 'FaultReason'=>array('name'=>'FaultReason', 'type'=>'xsd:string'), 'RowsFetched'=>array('name'=>'RowsFetched', 'type'=>'xsd:decimal'))); $server->wsdl->addComplexType('ReturnArray', 'complexType', 'array', 'all', '', array(), array('RntRecs'=>array('name'=>'RntRecs','type'=>'tns:ReturnRecords[]'), 'RecStat'=>array('name'=>'RecStat','type'=>'tns:RecordStatus'))); $server->register('oracle_err', array('InputParam' => 'xsd:string'), array('return' => 'tns:ReturnArray'), 'urn:oracle_err', 'urn:oracle_err#oracle_err', 'rpc', 'encoded', 'Testing Oracle connection.'); function oracle_err($InputParam) { //The connection details to make the database connection. require_once('cdbCred.php'); $date_stamp = date('M_d'); $db_results = array(); $results = array(); $LogFile = $log_dir . "Oracle_error_" . $date_stamp . ".log"; $record_size_limit = 64; //To control the size of the return array. $fptr = fopen($LogFile, 'a') or die("can't open file"); $sys_time = date('omd H:i:s'); fwrite($fptr,"\n\n***************************************\n"); fwrite($fptr,"* PHP - Start Time - ". $sys_time . "*\n"); fwrite($fptr,"***************************************\n"); fwrite($fptr,"PHP - IN WEB Service oracle_err()\n"); fwrite($fptr,"PHP - Source code - oracle_err.php\n"); //**** SETTING UP THE RETURN STRUCT variables **** $sys_time = date('omd H:i:s'); $rows_fetched= 0; $fault_reason= ' '; $error_status = 0; $tempArray = array('FirstVal' => "0", 'SecondVal' => "0", 'ThirdVal' => "0", 'FourthVal' => "0", 'FifthVal' => "0"); fwrite($fptr,"PHP - RECIEVED DATA\n"); fwrite($fptr,"PHP - InputParam =[". $InputParam ."]\n"); fwrite($fptr,"\n") ; $conn = oci_connect($user_name, $user_pswd, $user_database); if (!$conn) { $e = oci_error(); fwrite($fptr, "oci_error=[". $e['message'] . "]\n"); $rows_fetched= 0; $fault_reason= "Error - CONNECTING to ORACLE database.[" . $e['message'] ."]"; $error_status = 1; fwrite($fptr,"PHP - " . $fault_reason . "\n"); $reply_status = array('ErrStatus'=>$error_status, 'FaultReason'=>$fault_reason, 'RowsFetched'=>$rows_fetched); $RtnArray = array('RntRecs' => $tempArray, 'RecStat' => $reply_status); fwrite($fptr,"PHP - LEAVING THE PHP - " . date('omd H:i:s') . "\n"); fclose($fptr); return $RtnArray; } else { fwrite($fptr,"PHP - Connection to the ORACLE database successfull.\n"); } //*********************************************************** // LOADING the reply struct. //*********************************************************** $tempArray = array('FirstVal' => "FIRST", 'SecondVal' => "SECOND", 'ThirdVal' => "THIRD", 'FourthVal' => "FOURTH", 'FifthVal' => "FIFTH"); array_push($results,$tempArray); $tempArray = array('FirstVal' => "ONE", 'SecondVal' => "TWO", 'ThirdVal' => "THREE", 'FourthVal' => "FOUR", 'FifthVal' => "FIVE"); array_push($results,$tempArray); $reply_status = array('ErrStatus'=>$error_status, 'FaultReason'=>$fault_reason, 'RowsFetched'=>count($results)); $RtnArray = array('RntRecs' => $results, 'RecStat' => $reply_status); fwrite($fptr,"\n"); fwrite($fptr,"PHP - DISCONNECTING from ORACLE.\n\n"); oci_close($conn); fwrite($fptr,"PHP - LEAVING THE PHP - " . date('omd H:i:s') . "\n"); fclose($fptr); return $RtnArray; } $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; $server->service($HTTP_RAW_POST_DATA); ?> AND the call to the web service: <?php // Pull in the NuSOAP code require_once('../lib/nusoap.php'); date_default_timezone_set('Africa/Johannesburg'); $client = new nusoap_client('http://myserver/web/services/oracle_err?wsdl'); echo 'ORACLE ERROR simulation... <br>'; $input_parameter = "1"; $result = $client->call('oracle_err', array('InputParam'=>$input_parameter)); echo 'Back at the client<br>'; echo 'Result=['. $result .'] <br>'; echo 'Count of Result='. count($result) . '<br>'; if ($client->fault) { echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>'; } else { $err = $client->getError(); if ($err) { echo '<h2>Error</h2><pre>' . $err . '</pre>'; } else { echo '<h2>Result</h2><pre>'; print_r($result); echo '</pre>'; } } echo 'END'; ?> My dad loves these frozen cheeseburgers from meijer so I was gonna write a little script I can run in cron that will check Meijer's website and txt or email or something if they go on sale. Whenever I run the below script I get an Access Denied response from the server instead of the html for the cheesburger page. I'm sure I just need a CURL option or something. Thank You in Advance
The dreadful apostrophie problem... This search form returns an error whenever searching with an apostrophie (') Here's the code on the form (html) <td align="center" width="135"><form method="post" action="srch_advert.php"><input type=text name='search' size=15 maxlength=255><br><input type=submit></form></td> <td align="center" width="135"><form method="post" action="srch_details.php"><input type=text name='search' size=15 maxlength=255><br><input type=submit></form></td> <td align="center" width="135"><form method="post" action="srch_artist.php"><input type=text name='search' size=15 maxlength=255><br><input type=submit></form></td> <td align="center" width="135"><form method="post" action="srch_track.php"><input type=text name='search' size=15 maxlength=255><br><input type=submit></form></td> and heres the code on srch_advert.php if ($search) // perform search only if a string was entered. { mysql_connect($host, $user, $pass) or die ("Problem connecting to Database"); $srch="%".$search."%"; $query = "select * from tvads WHERE advert LIKE '$srch' ORDER BY advert, year DESC, details ASC LIMIT 0,30"; $result = mysql_db_query("cookuk_pn", $query); if(mysql_num_rows($result)==0) { print "<h2>Your search returned 0 Results</h2>"; } else if ($result) { can anyone see the problem here i am running php 5.3 on my server and GD seems to be enabled. and my host said it was probably something to do with the captcha files or script. <?php session_start(); /* * File: CaptchaSecurityImages.php * Author: Simon Jarvis * Copyright: 2006 Simon Jarvis * Date: 03/08/06 * Updated: 2007-08-12 by Jenny Ferenc (minor visual changes only) * Requirements: PHP 4/5 with GD and FreeType libraries * Link: http://www.white-hat-web-design.co.uk/articles/php-captcha.php * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details: * http://www.gnu.org/licenses/gpl.html * */ class CaptchaSecurityImages { var $font = 'VeraSe.ttf'; function generateCode($characters) { /* list all possible characters, similar looking characters and vowels have been removed */ $possible = '23456789bcdfghjkmnpqrstvwxyz'; $code = ''; $i = 0; while ($i < $characters) { $code .= substr($possible, mt_rand(0, strlen($possible)-1), 1); $i++; } return $code; } function CaptchaSecurityImages($width=130, $height=40, $characters=6) { $code = $this->generateCode($characters); // font size will be 60% of the image height $font_size = $height * 0.6; $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream'); // set the colours $background_color = imagecolorallocate($image, 255, 255, 255); $text_color = imagecolorallocate($image, 20, 40, 100); $noise_color = imagecolorallocate($image, 100, 120, 180); // generate random dots in background for( $i=0; $i<($width*$height)/3; $i++ ) { imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color); } // generate random lines in background for( $i=0; $i<($width*$height)/150; $i++ ) { imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color); } // create textbox and add text $textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function'); $x = ($width - $textbox[4])/2; $y = ($height - $textbox[5])/2; imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code) or die('Error in imagettftext function'); // output captcha image to browser header('Content-Type: image/jpeg'); imagejpeg($image); imagedestroy($image); $_SESSION['security_code'] = $code; } } $captcha = new CaptchaSecurityImages(); ?> this seems to be the problem line he Code: [Select] $textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function'); [\code] Trying for days to communicate to an IP camera from an apache server using PHP I do get responses from the camera RTSP/1.0 401 Unauthorized CSeq: 1 WWW-Authenticate: Digest realm="Login to 3E072F5PAL00180", nonce="bf2693784e774fb41b569ca02d8abe54" The nonce changes each time I refresh, I guess that is exactly what It should do. I read that I must MD5 the user and password along with some other data and create a string that goes back to the camera to authenticate and once done the camera replies RTSP/1.0 200 OK Somebody has a small bit of code to build the required answer from strings? I am not big in PHP,
I did find this on a page but it is way over my head, I do not have anything called $data.
$A1 = md5($data['username'] . ':' . $realm . ':' . $users[$data['username']]); $A2 = md5($_SERVER['REQUEST_METHOD'].':'.$data['uri']); $valid_response = md5($A1.':'.$data['nonce'].':'.$data['nc'].':'.$data['cnonce'].':'.$data['qop'].':'.$A2);
I get the idea of sending commands with an existing socket. socket_write($socket,$answer);
I have assigned directly as strings the password and user.
Greetings gurus, I need some help, please. I have a classic ASP background and now trying to get my feet wet with php. We have a web app that is used by several depts. I have been told to modify the app so that user is redirected to a site specific to their dept. For instance, if we have say, 3 deppts, HR, IT, and Payroll; if a user who belongs to the Payroll dept logs into the system, s/he will be redirected to PayRoll section of the page. I have done this tons of times using asp. Below is the code I used for asp: Code: [Select] 'Page = validateUser.asp SQL ="SELECT * FROM users " _ & " WHERE Username = '" & Request.Form("txtUserid") & "'" _ & " AND password = '" & Request.Form("TxtPassword") & "' " Set objRS = objConn.Execute( SQL ) If Not objRS.EOF Then If objRS("password") = Request.Form("txtPassword") Then Session.Contents("access_level") = objRS("access_level") Session.Contents("userID") = objRS("userID") 'ID column Session("username") = objRS("username") Session("password") = objRS("password") access_level = CInt(Session("access_level")) username = CStr(Session("username")) Select Case access_level Case 1 Response.Redirect "HRPage.asp" Case 2 Response.Redirect "PayrollPage.asp" Case 3 Response.Redirect "ITPage.asp" Case Else Response.Redirect "default.asp" End Select Else Response.Write "Sorry, but the password that you entered is incorrect." End If Else Response.Write "Sorry, but the username that you entered does not exist." End If objRS.Close Set objRS = Nothing objConn.Close Set objConn = Nothing Then on each page, I would do the check before redirecting the user: Code: [Select] If Session.Contents("access_level") <> 1 AND _ Session.Contents("access_level") <> 2 AND _ Session.Contents("access_level") Then Response.Redirect "default.asp" End If How I can use similar code in php? I hope you can assist me. Thanks very much This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=319071.0 Alright, first off, I'm fairly new to this aspect of web design. While I have been messing around and designing sites using your basic HTML/CSS/Flash for some time, I've decided to get into the more serious aspects of web design. As of right now, I'm using a fairly basic webhosting service that doesn't give me full administrative permission to MySQL because, as far as I can tell, the databases reside under their super-database and not on your actual allotted server. This creates a problem with creating a true MySQL database in which you set up users for their given tables you want them to be able to edit. Let me remind you here again that I am faily new to this aspect of web design, so maybe no one actually runs their databases in this way. My work around is to have the first table be the user/password table and only have a singular script that I call up every time my forms need to modify a table. I hide this small connection script in the root folder of my server where it is not viewable and just call it into my php scripts using 'include()' or 'get_file_contents.' What I'm asking here I guess is if this method is secure? And if anyone has any other ideas as to how to go about creating this database. Thanks in advance! I need to store the Login ID and Key for my Payment Gateway, and figured it was best to do this outside my web root ("httpdocs") on my VPS. Unfortunately, my PHP Include is breaking, and it looks like this is a *major* thing to get working, since requires me to tinker with Plesk's default settings in Linux. (This link seems to discuss the same issues I'm having: http://stackoverflow.com/questions/2370053/how-to-include-file-outside-document-root ) Anyways... Since I'm no Linux guru and afraid of breaking my VPS, how bad would it be to store my Authorize.net API ID and Key in a PHP file in my web root and include that file in my "checkout.php" file?? If anyone knows a reasonably easy way to fix the issue described in the link above, I'm all for it, but I am thinking I may have to just settle on leaving things in my web root... Thanks, Debbie In MVC type architecture, is it safe to do this ini_set("mysql.default_host"$mysql_host); ini_set("mysql.default_user",$mysql_user); ini_set("mysql.default_password",$mysql_pass); in my index.php file. Then, every time time I do a query in a model, mysql_connect(); // MySQL connects using the default values from the ini_sets we did. mysql_query($query); mysql_close(); The reason behind this, would be to avoid passing database variables to objects/models etc or defining constants. Maybe there's a better way? I'm looking into database abstraction. I'm getting an invalid argument error for my While loop. I can't figure out why. Code: [Select] $sql="SELECT * FROM schools ORDER BY class DESC,sectional ASC,team ASC"; $results = mysql_query($sql); while ($team = mysql_fetch_assoc($results)) { echo $team['school'] . '<br>'; } Here is the error: Quote Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/******/public_html/hoosierhoopsmagazine.com/resources/sectional_assignments.php on line 7 hi there, i am fairly new to OOPs in php, i get an error when i declare the argument type (as object) in a function and pass the same type (object). class eBlast { public static function getEmail(object $result) { return $result->email; } } $r = mysql_fetch_object($query); eBlast::getEmail($r); echo gettype($r); // outputs: object error is : Code: [Select] Catchable fatal error: Argument 1 passed to eBlast::getEmail() must be an instance of object, instance of stdClass given, called in C:\wamp\www\integra\client\pl_eblast\admin\send_emails.php on line 145 and defined in C:\wamp\www\integra\client\pl_eblast\app\app.eBlast.php on line 8 if i remove the type declaration in the function it works, but just would like to know why it shows error when pass the same type, also isnt mysql_fetch_object is the instance of stdclass? thanks in advance! How can I prevent someone from making an ivalid selection in a form? Lets say I had a select dropdown box and someone saved the HTML source from the browser, changed an item in the list, and changed the action to point back to my server eg. action="testsite.com/index.php". Then they open the file and try to submit the form.
|