accountExpires

Help
purephase
2007-02-24
2013-05-20
  • purephase

    purephase - 2007-02-24

    Anyone successfully modify the accountExpires attribute with adLDAP (or with ldap_modify period). I keep getting the following error message:

    Warning: ldap_modify() [function.ldap-modify]: Modify: Invalid syntax

    This is the code I'm using:
    // The convert_date_integer8 function converts a regular date (DD/MM/YYYY) into the accountExpires format required by AD.
    // I've verified the values from this function through ADSIEdit and they're correct.
    $integer8_expiry_date = convert_date_integer8($unformatted_expiry_date);

    $expiry_date_change = $ad->user_modify($_SESSION['Accounts_Results_username'], array('expires' => $integer8_expiry_date, 'enabled' => true));

    If I remove the expires attribute, the enable works fine (other attributes like description work as well). But each time I include the expires attribute it fails. I even tried modifying the class so that the following line reads:

    if ($attributes["expires"]){ $mod["accountexpires"][0]=$attributes["expires"]; } //unix epoch format?

    (Previously, the $mod["accountexpires"] array value was $mod["account_expires"]. There is no underscore in the schema attribute.)

    Any advice would be appreciated. Thanks.

     
    • Anonymous - 2007-07-17

      What does that function look like? convert_date_integer8? so I can give it a try.

       
      • c00p

        c00p - 2007-08-29

        What was causing your problem was the decimal point '.' at the end of the generated time stamp. so what I have done has pulled out the characters before the decimal point in the string.

        I believe this length will not change, if it does I could also do with with a regular expression. But here is the modified version of the function that may be included in the new adLDAP? I will also show some code I have made that I wish to share soon for use with this great class :)

        // Convert a date value to an Integer8 format. MM/DD/YYYY format only.
        function convert_date_int8($date) {
                $date_array = explode("/", $date);
                $unix_timestamp = mktime(0,0,0, $date_array[0], $date_array[1], $date_array[2]);
                $unix_timestamp += 11644560000;
                $unix_timestamp *= 10000000;

                $float = sprintf('%f', $unix_timestamp);
                //$integer = sprintf('%d', $unix_timestamp);

                //echo "INT = $integer";
                //echo "FLOAT = $float";

                //if ($float == $integer) {
                        // this is a whole number, so remove all decimals
                        //$output = $integer;
                //      return $integer;
        //      }
        //      else {
                        // remove trailing zeroes from the decimal portion
                        //$output = rtrim($float,'0');
                        return substr($float, 0, 18);
        //      }
        //      return $output;
        }

         
    • Derek Ethier

      Derek Ethier - 2007-07-26

      // Convert a date value to an Integer8 format. MM/DD/YYYY format only.
      function convert_date_integer8($date) {
          $date_array = explode("/", $date);

          $unix_timestamp = mktime(0,0,0, $date_array[0], $date_array[1], $date_array[2]);

          $unix_timestamp += 11644560000;
          $unix_timestamp *= 10000000;

          $float         = sprintf('%f', $unix_timestamp);
          $integer     = sprintf('%d', $unix_timestamp);

          if ($float == $integer) {
              // this is a whole number, so remove all decimals
              $output = $integer;
          }
          else {
              // remove trailing zeroes from the decimal portion
              $output = rtrim($float,'0');
          }

          return $output;
      }

       
    • c00p

      c00p - 2007-08-29

      // Convert a date value to an Integer8 format. MM/DD/YYYY format only.
      function convert_date_int8($date) {
              if(!ereg("[0-1][0-9]/[0-3][0-9]/20[0-9][0-9]", $date)) {
                      echo "Conv Date: Error with Specified Date";
                      return false;
              }
              $dArray = explode("/", $date);
              $unix_timestamp = mktime(0,0,0, $dArray[0], $dArray[1], $dArray[2]);            
              $unix_timestamp += 11644560000;
              $unix_timestamp *= 10000000;

              $float = sprintf('%f', $unix_timestamp);
              return substr($float, 0, 18);
      }

      That is what I am using now ...

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks