Plugin Directory

Changeset 997202


Ignore:
Timestamp:
09/26/2014 01:56:53 PM (12 years ago)
Author:
glatze
Message:

Added attribute type "cn"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • active-directory-integration/trunk/ad-integration.php

    r674096 r997202  
    21372137                        $parts[1] = strtolower(trim($parts[1]));
    21382138                    }
    2139                     if (!in_array($parts[1], array('string','list','integer','bool','time','timestamp','octet'))) {
     2139                    if (!in_array($parts[1], array('string','list','integer','bool','time','timestamp','octet','cn'))) {
    21402140                        $parts[1] = 'string';
    21412141                    }
     
    22032203     * Returns formatted value according to attribute type
    22042204     *
    2205      * @param string $type (string, integer, bool, time, timestamp, octet)
     2205     * @param string $type (string, integer, bool, time, timestamp, octet, cn)
    22062206     * @param mixed $value
    22072207     * @return mixed formatted value
     
    22252225                return date_i18n(get_option('date_format','Y-m-d').' / '.get_option('time_format','H:i:s'), $timestamp, true);
    22262226            case 'octet': return base64_encode($value);
     2227               
     2228            case 'cn': // Get CN from string
     2229                $pos = stripos($value,'cn=');
     2230                if ($pos !== false) {
     2231                    $start =  $pos+3;
     2232                    $foundEnd = false;
     2233                    $valueLength = strlen($value);
     2234                    for ($x = $start; $x < $valueLength; $x++) {
     2235                        if ($value[$x] == ',') {
     2236                            if ($value[$x-1] !== '\\') {
     2237                                break;
     2238                            }
     2239                        }
     2240                    }
     2241                    return stripslashes(substr($value, $start, $x - $start));
     2242                } else {
     2243                    return '';
     2244                }
     2245           
    22272246        }
    22282247        return $value;
Note: See TracChangeset for help on using the changeset viewer.