Instance($server_id); // Unique to this template $step = isset( $_POST['step'] ) ? $_POST['step'] : 1; if( ! $ldapserver->haveAuthInfo()) pla_error( $lang['not_enough_login_info'] ); if( $step == 1 ) { $oclasses = $ldapserver->SchemaObjectClasses(); if( ! $oclasses || ! is_array( $oclasses ) ) pla_error( "Unable to retrieve the schema from your LDAP server. Cannot continue with creation." ); ?>
SchemaObjectClasses(); $required_attrs = array(); $all_attrs = array(); foreach( $oclasses as $oclass_name ) { $oclass = $ldapserver->getSchemaObjectClass($oclass_name); if( $oclass ) { $required_attrs = array_merge( $required_attrs, $oclass->getMustAttrNames( $schema_oclasses ) ); $all_attrs = array_merge( $all_attrs, $oclass->getMustAttrNames( $schema_oclasses ), $oclass->getMayAttrNames( $schema_oclasses ) ); } } $required_attrs = array_unique( $required_attrs ); $all_attrs = array_unique( $all_attrs ); remove_aliases( $required_attrs, $ldapserver ); remove_aliases( $all_attrs, $ldapserver ); sort( $required_attrs ); sort( $all_attrs ); // if for some reason "ObjectClass" ends up in the list of // $all_attrs or $required_attrs, remove it! This is a fix // for bug 927487 foreach( $all_attrs as $i => $attr_name ) if( 0 == strcasecmp( $attr_name, 'objectClass' ) ) { unset( $all_attrs[$i] ); $all_attrs = array_values( $all_attrs ); break; } foreach( $required_attrs as $i => $attr_name ) if( 0 == strcasecmp( $attr_name, 'objectClass' ) ) { unset( $required_attrs[$i] ); $required_attrs = array_values( $required_attrs ); break; } // remove binary attributes and add them to the binary_attrs array $binary_attrs = array(); foreach( $all_attrs as $i => $attr_name ) { if( is_attr_binary( $ldapserver, $attr_name ) ) { unset( $all_attrs[ $i ] ); $binary_attrs[] = $attr_name; } } // If we trim any attrs out above, then we will have a gap in the index // sequence and will get an "undefined index" error below. This prevents // that from happening. $all_attrs = array_values( $all_attrs ); // add the required attribute based on the RDN provided by the user // (ie, if the user specifies "cn=Bob" for their RDN, make sure "cn" is // in the list of required attributes. $rdn_attr = trim( substr( $rdn, 0, strpos( $rdn, '=' ) ) ); $rdn_value = trim( substr( $rdn, strpos( $rdn, '=' ) + 1 ) ); $rdn_value = @pla_explode_dn( $rdn ); $rdn_value = @explode( '=', $rdn_value[0], 2 ); $rdn_value = @$rdn_value[1]; if( in_array( $rdn_attr, $all_attrs ) && ! in_array( $rdn_attr, $required_attrs ) ) $required_attrs[] = $rdn_attr; ?>