You can also use dsconfig in non-interactive command-line mode to create a mirror virtual attribute. The following example sets up the managerName virtual attribute introduced in the previous section:

  1. Update the schema to define the managerName attribute. In a text editor, create a file with the following schema definition for the attribute and save it as 98-myschema.ldif, for example, in the <server-root>/config/schema folder. You can optionally add the attribute to an object class.
    dn: cn=schema 
    objectClass: top 
    objectClass: ldapSubent
    objectClass: subschema attributeTypes: ( NAME ‘managerName’ 
      EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX{256} 
      X-ORIGIN ‘Directory Server Example’ )
  2. Restart the Directory Server.
    $ bin/stop-server --restart
  3. Use dsconfig to create the virtual attribute.
    $ bin/dsconfig create-virtual-attribute \ 
      --name "managerName" \ 
      --type mirror \ 
      --set "description:managerName from manager cn" \ 
      --set enabled:true \
      --set attribute-type:managerName \ 
      --set source-attribute:cn \
      --set source-entry-dn-attribute:manager
  4. Verify the mirror virtual attribute by searching for an entry.
    $ bin/ldapsearch --baseDN dc=example,dc=com "(uid=apeters)"
    dn: uid=apeters,ou=People,dc=example,dc=com 
    ... (attributes) ... 
    manager: uid=jdoe,ou=People,dc=example,dc=com 
    managerName: John Doe