Jump to content

pakenney38

Members
  • Posts

    90
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

pakenney38's Achievements

Member

Member (2/5)

0

Reputation

  1. Apparently I got some incorrect documentation. The command I am supposed to be using is ldap_add(), not ldap_mod_add().
  2. Subsequently, if I try to run this: <?PHP $ldaprdn = 'user@test.local'; $ldappass = 'password'; $ds = 'server.test.local'; $dn = 'dc=test,dc=local'; $ldapport = 389; $ldapconn = ldap_connect($ds, $ldapport) or die("Could not connect to LDAP server."); if ($ldapconn) { ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION,3); ldap_set_option($ldapconn, LDAP_OPT_REFERRALS,0); $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass); if ($ldapbind) { echo "LDAP bind successful..."; $attr["cn"] = "ROSE TWILL"; $attr["objectClass"] = "contact"; $attr["sn"] = "TWILL"; $attr["givenName"] = "ROSE"; $attr["displayName"] = "ROSE TWILL (2nd Server)"; $attr["mailNickname"] = "RTWILL"; $attr["targetAddress"] = "smtp:RTWILL@domain.com"; $attr["mail"] = "RTWILL@domain.com"; $attr["proxyAddresses"] = "smtp:RTWILL@domain.net"; $result = ldap_mod_add($ldapconn, "ou=Mail Enable,ou=Test Users,ou=Test,dc=test,dc=local", $attr); } else { echo "LDAP bind failed..."; } } ldap_close($ldapconn); ?> I get back: LDAP bind successful... Warning: ldap_mod_add() [function:ldap-mod-add]: Modify: Server is unwilling to perform in C:\Intepub\wwwroot\newcontact.php on line 29 What so now Active Directory is just telling me "no" ?
  3. I am trying to use PHP to insert a contact into Windows Server 2003 Active Directory. I do this: <?PHP $ldaprdn = 'user@test.local'; $ldappass = 'password'; $ds = 'server.test.local'; $dn = 'dc=test,dc=local'; $ldapport = 389; $ldapconn = ldap_connect($ds, $ldapport) or die("Could not connect to LDAP server."); if ($ldapconn) { ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION,3); ldap_set_option($ldapconn, LDAP_OPT_REFERRALS,0); $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass); if ($ldapbind) { echo "LDAP bind successful..."; $attr["cn"][0] = "ROSE TWILL"; $attr["objectclass"][0] = "top"; $attr["objectclass"][1] = "person"; $attr["objectclass"][2] = "organizationalPerson"; $attr["objectClass"][3] = "contact"; $attr["sn"][0] = "TWILL"; $attr["givenName"][0] = "ROSE"; $attr["displayName"][0] = "ROSE TWILL (2nd Server)"; $attr["mailNickname"][0] = "RTWILL"; $attr["targetAddress"][0] = "smtp:RTWILL@domain.com"; $attr["mail"][0] = "RTWILL@domain.com"; $attr["proxyAddresses"][0] = "smtp:RTWILL@domain.net"; $result = ldap_mod_add($ldapconn, "ou=Mail Enable,ou=Test Users,ou=Test,dc=test,dc=local", $attr); } else { echo "LDAP bind failed..."; } } ldap_close($ldapconn); ?> I get this: LDAP bind successful... Warning: ldap_mod_add() [function.ldap-mod-add]: Value array must have consecutive indices 0, 1, ... in C:\Inetpub\wwwroot\newcontact.php on line 32 What does this mean and what am I doing wrong? I appreciate any help on this.
  4. That's kind of what I was asking. Can CONCAT be used in the WHERE clause instead of at the beginning of the SELECT statement?
  5. There is a table named tablename. And in tablename there are 3 columns: col1, col2, col3. I want to SELECT * FROM tablename WHERE col1 is equal to the concatenation of col2 and col3.
  6. Thanks. That will work. I had done that once before and forgot I could do it that way.
  7. Assume that the first numerical index of a given array is 0. Is there any way to find the highest numerical index of the array? I want to avoid using something like, if I can: $highest_index = count($array) - 1;
  8. Good point. Sorry for the confusion. Thanks for the solution.
  9. Thanks! That gets me a lot closer. Is there any way I could check to see if $str[2] equals any value within an array? Say I have: $suffixes = array('JR', 'SR', 'I', 'II', 'III', 'IV'); I realize I would have to find the number of elements in $str, but can I just do: $str = 'JOHN DOE JR'; $tmp = explode(' ',$str); if $str[2] == $suffixes { array_pop($tmp); $new_str = implode(' ',$tmp); } Sorry I don't mean to be a complete noob, but how would I work the if statement?
  10. I tried that and unfortunately there are several names in the list that are multiple words with words beginning with " I", so that will not work.
  11. Say I have a string like "JOHN DOE JR". Does anyone know the best way to truncate suffixes like " JR" from the name? I need to be able to truncate " JR", " SR", " I", " II", " III", " IV", etc on a large list of names. The names are stored in MySQL if it matters.
  12. Thanks, but that's the way it was originally and it produced the same effect.
  13. I really don't know how to explain this, but I have a Tab-delimited file that I want to read line-by-line. In a line is an employee number. I want to get the lastname and firstname of the employee from a MySQL table using the employee number as the relative key. I want to do this for each line then display the results on the screen. The problem is that the script gets the firstname and lastname of the employees until it hits an employee that is not in the MySQL table, then it fails to get the firstname and lastname for the remainder of the employees, even if some of them are in the MySQL table. Here is my example: <?PHP $host = "XXX"; $user = "XXX"; $pwd = "XXX"; $filename = "C:\aaron.csv"; $fh = fopen($filename, 'r'); $theData = fread($fh, filesize($filename)); fclose($fh); $line = explode("\r\n", $theData); mysql_connect($host, $user, $pwd); mysql_select_db("database") or die("Error: " . mysql_error()); foreach ($line as $key => $value) { $info = explode("\t", $value); $info[1] = trim($info[1]); $empno = $info[1]; echo $info [1]; echo "<br>"; echo $empno; echo "<br>"; $query = "SELECT lastname, firstname FROM name WHERE empnumber = '$empno'"; $result = mysql_query($query); $row = mysql_fetch_array($result); $lastname = $row['lastname']; $firstname = $row['firstname']; echo $row['lastname']; echo "<br>"; echo $lastname; echo "<br>"; echo $row['firstname']; echo "<br>"; echo $firstname; echo "<br><br>"; } mysql_close(); ?> Any help would be great thank you. This is driving me nuts.
  14. I am going to have to go back through my PHP documentation. Who's to say there isn't a function in PHP for what I want? There are many many MySQL-based functions in PHP.
  15. The first example did not work tried it several ways. Always resulted in a MySQL error or PHP error. So I guess it is back to putting it through multiple elseif statements. This is not really a big deal, but I consider this to be a complete disregard for time and money from a project management perspective.
×
×
  • 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.