ldapservers->Instance($server_id_src); if (! $ldapserver_src->haveAuthInfo()) pla_error(_('Not enough information to login to server. Please check your configuration.')); $ldapserver_dst = $_SESSION[APPCONFIG]->ldapservers->Instance($server_id_dst); if (! $ldapserver_src->haveAuthInfo()) pla_error(_('Not enough information to login to server. Please check your configuration.')); if (! $ldapserver_src->dnExists($dn_src)) pla_error(sprintf(_('No such entry: %s'),pretty_print_dn($dn_src))); if (! $ldapserver_dst->dnExists($dn_dst)) pla_error(sprintf(_('No such entry: %s'),pretty_print_dn($dn_dst))); $attrs_src = $ldapserver_src->getDNAttrs($dn_src,false,$_SESSION[APPCONFIG]->GetValue('deref','view')); $attrs_dst = $ldapserver_dst->getDNAttrs($dn_dst,false,$_SESSION[APPCONFIG]->GetValue('deref','view')); # Get a list of all attributes. $attrs_all = array_keys($attrs_src); foreach ($attrs_dst as $key => $val) if (! in_array($key,$attrs_all)) $attrs_all[] = $key; printf('

%s

',_('Comparing the following DNs')); echo ''; echo ''; printf('',_('Attribute')); printf('', _('Server'),$ldapserver_src->name,_('Distinguished Name'),htmlspecialchars($dn_src)); printf('', _('Server'),$ldapserver_dst->name,_('Distinguished Name'),htmlspecialchars($dn_dst)); echo ''; echo ''; echo ''; echo ''; if (! $attrs_all || ! is_array($attrs_all)) { printf('',_('This entry has no attributes')); print '

%s
 

%s: %s
%s: %s

%s: %s
%s: %s

'; echo '
'; printf('',$ldapserver->server_id); printf('',$ldapserver_dst->server_id); printf('',$ldapserver_src->server_id); printf('',htmlspecialchars($dn_dst)); printf('',htmlspecialchars($dn_src)); printf('',_('Switch Entry')); echo '
'; echo '
(%s)
'; return; } sort($attrs_all); $formdisplayed = false; # Work through each of the attributes. foreach ($attrs_all as $attr) { # If this is the DN, get the next attribute. if (! strcasecmp($attr,'dn')) continue; # Has the config.php specified that this attribute is to be hidden or shown? if ($ldapserver_src->isAttrHidden($attr) || $ldapserver_dst->isAttrHidden($attr)) continue; $schema_attr_src = $ldapserver_src->getSchemaAttribute($attr,$dn_src); $schema_attr_dst = $ldapserver_dst->getSchemaAttribute($attr,$dn_dst); # Get the values and see if they are the same. if (isset($attrs_src[$attr]) && isset($attrs_dst[$attr]) && $attrs_src[$attr] === $attrs_dst[$attr]) echo ''; else echo ''; foreach (array('src','dst') as $side) { # Setup the $attr_note, which will be displayed to the right of the attr name (if any) $attr_note = ' '; # is there a user-friendly translation available for this attribute? if ($_SESSION[APPCONFIG]->haveFriendlyName($attr)) { $attr_display = $_SESSION[APPCONFIG]->getFriendlyName($attr); $attr_note = sprintf('%s',_('Note'),$attr_display,_('is an alias for'),$attr,_('alias')); } else { $attr_display = $attr; $attr_note = ' '; } # is this attribute required by an objectClass? $required_by = ''; switch ($side) { case 'src': $ldapserver = $ldapserver_src; if ($schema_attr_src) foreach ($schema_attr_src->getRequiredByObjectClasses() as $required) if (isset($attrs_src['objectClass']) && in_array(strtolower($required),arrayLower($attrs_src['objectClass']))) $required_by .= $required . ' '; # It seems that some LDAP servers (Domino) returns attributes in lower case? elseif (isset($attrs_src['objectclass']) && in_array(strtolower($required),arrayLower($attrs_src['objectclass']))) $required_by .= $required . ' '; break; case 'dst': $ldapserver = $ldapserver_dst; if ($schema_attr_dst) foreach ($schema_attr_dst->getRequiredByObjectClasses() as $required) if (isset($attrs_dst['objectClass']) && in_array(strtolower($required),arrayLower($attrs_dst['objectClass']))) $required_by .= $required . ' '; # It seems that some LDAP servers (Domino) returns attributes in lower case? elseif (isset($attrs_dst['objectclass']) && in_array(strtolower($required),arrayLower($attrs_dst['objectclass']))) $required_by .= $required . ' '; break; } # If we are on the source side, show the attr if ($side == 'src') { echo ''; $schema_href = sprintf('cmd.php?cmd=schema&server_id=%s&view=attributes&viewvalue=%s',$server_id_src,real_attr_name($attr)); printf('%s',sprintf(_('Click to view the schema definition for attribute type \'%s\''),$attr),$schema_href,$attr_display); echo ''; printf('%s',$attr_note); } echo ''; # Create our form if the dst is editable. if ($side == 'dst' && ! $ldapserver_dst->isReadOnly() && ! $formdisplayed) { $formdisplayed = true; echo '
'; printf('',$ldapserver_dst->server_id); printf('',$dn_dst); } if ($required_by) printf('%s',sprintf(_('Required attribute for objectClass(es) %s'),$required_by),_('required')); echo ''; if ($ldapserver->isAttrReadOnly($attr)) printf('(%s)',_('This attribute has been flagged as read only by the phpLDAPadmin administrator'),_('read only')); } echo ''; if (isset($attrs_src[$attr]) && isset($attrs_dst[$attr]) && $attrs_src[$attr] === $attrs_dst[$attr]) echo ''; else echo ''; foreach (array('src','dst') as $side) { $vals = null; # If this attribute isnt set, then show a blank. $toJump = 0; switch ($side) { case 'src': print ' '; if (! isset($attrs_src[$attr])) { echo "<". _('No Value').">"; $toJump = 1; continue; } else $vals = $attrs_src[$attr]; $ldapserver = $ldapserver_src; break; case 'dst': print ' '; if (! isset($attrs_dst[$attr])) { echo "<". _('No Value').">"; $toJump = 1; continue; } else $vals = $attrs_dst[$attr]; $ldapserver = $ldapserver_dst; break; } if ($toJump) continue; if (! is_array($vals)) $vals = array($vals); # Is this attribute a jpegPhoto? if ($ldapserver->isJpegPhoto($attr)) { switch ($side) { case 'src': # Don't draw the delete buttons if there is more than one jpegPhoto (phpLDAPadmin can't handle this case yet) draw_jpeg_photos($ldapserver,$dn_src,$attr,false); break; case 'dst': if ($ldapserver_dst->isReadOnly() || $ldapserver_dst->isAttrReadOnly($attr)) draw_jpeg_photos($ldapserver,$dn_dst,$attr,false); else draw_jpeg_photos($ldapserver,$dn_dst,$attr,true); break; } # proceed to the next attribute echo ''."\n"; continue; } # Is this attribute binary? if ($ldapserver->isAttrBinary($attr)) { switch ($side) { case 'src': $href = sprintf("download_binary_attr.php?server_id=%s&dn=%s&attr=%s",$ldapserver->server_id,$encoded_dn_src,$attr); break; case 'dst': $href = sprintf("download_binary_attr.php?server_id=%s&dn=%s&attr=%s",$ldapserver->server_id,$encoded_dn_dst,$attr); break; } echo ''; echo _('Binary value'); echo '
'; if (count($vals) > 1) for ($i=1; $i<=count($vals); $i++) printf(' %s(%s)
',$href,$i,_('download value'),$i); else printf(' %s
',$href,_('download value')); if ($side == 'dst' && ! $ldapserver_dst->isReadOnly() && ! $ldapserver->isAttrReadOnly($attr)) printf(' %s',$attr,_('delete attribute')); echo '
'; echo ''; continue; } # Note: at this point, the attribute must be text-based (not binary or jpeg) /* * If this server is in read-only mode or this attribute is configured as read_only, * simply draw the attribute values and continue. */ if ($side == 'dst' && ($ldapserver->isReadOnly() || $ldapserver->isAttrReadOnly($attr))) { if (is_array($vals)) { foreach ($vals as $i => $val) { if (trim($val) == '') printf('[%s]
',_('empty')); elseif (strcasecmp($attr,'userPassword') == 0 && $_SESSION[APPCONFIG]->GetValue('appearance','obfuscate_password_display')) echo preg_replace('/./','*',$val).'
'; else echo htmlspecialchars($val).'
'; } # @todo: redundant - $vals is always an array. } else { if (strcasecmp($attr,'userPassword') == 0 && $_SESSION[APPCONFIG]->GetValue('appearance','obfuscate_password_display')) echo preg_replace('/./','*',$vals).'
'; else echo $vals.'
'; } echo ''; continue; } # Is this a userPassword attribute? if (! strcasecmp($attr,'userpassword')) { $user_password = $vals[0]; $enc_type = get_enc_type($user_password); # Set the default hashing type if the password is blank (must be newly created) if ($user_password == '') { $enc_type = get_default_hash($server_id); } if ($side == 'dst') { printf('',htmlspecialchars($user_password)); echo ''; printf('',$enc_type == '' ? 'clear' : $enc_type); } if (obfuscate_password_display($enc_type)) echo htmlspecialchars(preg_replace('/./','*',$user_password)); else echo htmlspecialchars($user_password); echo '
'; if ($side == 'dst') { printf('',htmlspecialchars($user_password)); echo enc_type_select_list($enc_type); } echo '
'; ?> %s',_('Check password')); echo ''; continue; } # Is this a boolean attribute? if ($ldapserver->isAttrBoolean($attr)) { $val = $vals[0]; if ($side = 'dst') { printf('',htmlspecialchars($attr),htmlspecialchars($val)); printf(''; } echo ''; continue; } # End of special case attributes (non plain text). foreach ($vals as $i => $val) { if ($side == 'dst') { $input_name = sprintf('new_values[%s][%s]',htmlspecialchars($attr),$i); /* We smack an id="..." tag in here that doesn't have [][] in it to allow the * draw_chooser_link() to identify it after the user clicks.*/ $input_id = sprintf('"new_values_%s_%s',htmlspecialchars($attr),$i); echo ''; printf('',htmlspecialchars($attr),$i,htmlspecialchars($val)); } # Is this value is a structural objectClass, make it read-only if (0 == strcasecmp($attr,'objectClass')) { printf('', _('View the schema description for this objectClass'),$ldapserver->server_id,htmlspecialchars($val)); $schema_object = $ldapserver->getSchemaObjectClass($val); if ($schema_object->getType() == 'structural') { printf('%s (%s)
', $val,_('This is a structural ObjectClass and cannot be removed.'),_('structural')); if ($side == 'dst') printf('',$input_name,$input_id,htmlspecialchars($val)); continue; } } if (is_dn_string($val) || $ldapserver->isDNAttr($attr)) printf('', sprintf(_('Go to %s'),htmlspecialchars($val)),$ldapserver->server_id,rawurlencode($val)); elseif (is_mail_string($val)) printf('',htmlspecialchars($val)); elseif (is_url_string($val)) printf('',htmlspecialchars($val)); if ($ldapserver->isMultiLineAttr($attr,$val)) { if ($side == 'dst') printf('',$input_name,$input_id,htmlspecialchars($val)); else echo htmlspecialchars($val); } else { if ($side == 'dst') printf('',$input_name,$input_id,htmlspecialchars($val)); else echo htmlspecialchars($val); } # draw a link for popping up the entry browser if this is the type of attribute that houses DNs. if ($ldapserver->isDNAttr($attr)) draw_chooser_link("edit_form.$input_id",false); echo '
'; } echo ''; } /* end foreach value */ echo ''; # Draw the "add value" link under the list of values for this attributes if (! $ldapserver_dst->isReadOnly()) { # First check if the required objectClass is in this DN $isOK = 0; $src_oclass = array(); $attr_object = $ldapserver_dst->getSchemaAttribute($attr,$dn_dst); foreach ($attr_object->used_in_object_classes as $oclass) { if (in_array(strtolower($oclass),arrayLower($attrs_dst['objectClass']))) { $isOK = 1; break; } else { # Find oclass that the source has that provides this attribute. if (in_array($oclass,$attrs_src['objectClass'])) $src_oclass[] = $oclass; } } echo '  '; if (! $isOK) { if (count($src_oclass) == 1) $add_href = sprintf('cmd.php?cmd=add_oclass_form&server_id=%s&dn=%s&new_oclass=%s', $ldapserver_dst->server_id,$encoded_dn_dst,$src_oclass[0]); else $add_href = sprintf('cmd.php?cmd=add_value_form&server_id=%s&dn=%s&attr=objectClass', $ldapserver_dst->server_id,$encoded_dn_dst); if ($attr == 'objectClass') printf('
(%s)
',$add_href,_('Add ObjectClass and Attributes'),_('add value')); else printf('
(%s)
', $add_href,sprintf(_('You need one of the following ObjectClass(es) to add this attribute %s.'),implode(" ",$src_oclass)), _('Add new ObjectClass')); } else { if (! $schema_attr_dst->getIsSingleValue() || (! isset($vals))) { $add_href = sprintf('cmd.php?cmd=add_value_form&erver_id=%s&dn=%s&attr=%s', $ldapserver_dst->server_id,$encoded_dn_dst,rawurlencode($attr)); printf('
(%s)
', $add_href,sprintf(_('Add an additional value to attribute \'%s\''),$attr),_('add value')); } } } echo ''; # Get the values and see if they are the same. if (isset($attrs_src[$attr]) && isset($attrs_dst[$attr]) && $attrs_src[$attr] === $attrs_dst[$attr]) echo ''; else echo ' '; } /* End foreach ($attrs as $attr => $vals) */ if (! $ldapserver_dst->isReadOnly()) printf(' 
',_('Save Changes')); echo ''; # If this entry has a binary attribute,we need to provide a form for it to submit when deleting it. */ ?>