Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Undefined offset

    Im having problems with a script. When it is run I get the following error

    PHP Notice: Undefined offset: 0 in xxx on line 103

    Here is the code



    /* LDAP Code begin */
    + $ldap = array('ldaphost' => 'ldap.admod.com',
    + 'ldaprdn' => 'cn=authcheck,ou=System,ou=Accounts,dc=admod,dc=com',
    + 'ldappass' => 'xxxxxxxxx',
    + 'dn' => 'ou=People,ou=Accounts,dc=admod,dc=com');
    + $info = array();
    + $ldapconn = ldap_connect($ldap['ldaphost']);
    + ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
    + $ldapbind = ldap_bind($ldapconn, $ldap['ldaprdn'], $ldap['ldappass']);
    + $username = $form['username'];
    + $password = $form['password'];
    + $filter = "(&(uid=$username) (accountStatus=active))";
    + $sr = ldap_search($ldapconn, $ldap['dn'], $filter);
    + $info = ldap_get_entries($ldapconn, $sr);
    + if (!empty($info)) {
    + $sr = ldap_compare($ldapconn, $info[0]["dn"], "userPassword", '{MD5}' . base64_encode(pack('H*', md5($password))));
    + }


    I've not written this code myself, and Im not sure what is wrong. The line this error is referring to is here

    $sr = ldap_compare($ldapconn, $info[0]["dn"],


    Anyone have any clues?
    Last edited by Silverflames; 10-09-2009 at 02:24 PM.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Well your $info array doesn't contain a value for the "0" index. Your check if (!empty($info)) { isn't doing the job; you really need to be checking for that "0" index instead using isset().

    PHP Code:
    if (isset($info[0])) { 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •