Skip Headers
Oracle® Fusion Middleware Administrator's Guide for Oracle Internet Directory
11g Release 1 (11.1.1)

Part Number E10029-06
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

19 Managing Attribute Uniqueness Constraint Entries

This chapter explains attribute uniqueness in Oracle Internet Directory. It contains these topics:

19.1 Introduction to Managing Attribute Uniqueness Constraint Entries

When you use the LDAP tools, the attribute uniqueness feature prevents duplication of attribute values, both when adding and modifying them. For example, it prevents you from assigning to a new employee an identifier already assigned to another employee. Instead, the directory server terminates the operation and returns an error message.

You can define attribute uniqueness:

Note:

The LDAP tools support attribute uniqueness. The bulk tools do not.

To implement attribute uniqueness, you create an attribute uniqueness constraint entry in which you provide values for the attributes shown in Table 19-1.

Attribute uniqueness constraint entries are stored under cn=unique,cn=Common,cn=Products,cn=OracleContext.

Table 19-1 Attribute Uniqueness Constraint Entry

Attribute Name Mandatory? Valid Value Default Value Default Effect

orcluniqueattrname

Yes

Any string

N/A

N/A

orcluniquescope

No

One of the following:

  • base: Searches the root entry only

  • onelevel: Searches one level only

  • sub: Searches the entire directory

sub

Searches the entire directory

orcluniqueenable

No

Either 0 (disable) or 1 (enable)

0

Disables attribute uniqueness

orcluniquesubtree

No

Any string

" "

Searches the entire directory

orcluniqueobjectclass

No

Any string

" "

Searches all object classes


When you have created the entry and specified the attributes, before it performs an operation, the directory server:

If an operation applies to a monitored attribute, suffix, or object class, and would cause two entries to have the same attribute value, then the directory server terminates the operation and returns a constraint violation error message to the client.

Note:

The attribute uniqueness feature works on indexed attributes only.

When an attribute uniqueness constraint is present in the Oracle Internet Directory replication environment, be careful about configuring the attribute uniqueness constraints on each server.

This section contains these topics:

Simple Replication Scenario

Because all modifications by client applications are performed on the supplier server, the attribute uniqueness constraint should be enabled on that server. It is not necessary to enable the attribute uniqueness constraint on the consumer server. Enabling the attribute uniqueness constraint on the consumer server does not prevent the directory server from operating correctly, but it can cause a performance degradation.

Multimaster Replication Scenario

In a multimaster replication scenario, nodes serve as both suppliers and consumers of the same replica. Multimaster replication uses a loosely consistent replication model.

Enabling an attribute uniqueness constraint on one of the servers does not ensure that attribute values are unique across both masters at any given time. Enabling an attribute uniqueness constraint on only one server can cause inconsistencies in the data held on each replica.

The attribute uniqueness constraint must be enabled on both masters. However, there may still be an inconsistent state. For example, in both masters we can successfully modify entries to the same attribute value. However, when the changes are later replicated to the other node, the conflict becomes apparent. You must take this type of conflict resolution into consideration as well, deciding whether conflict resolution should be the replication server's responsibility.

19.2 Cleaning Up Duplicate Attribute Values

Beginning with Oracle Internet Directory 11g Release 1 (11.1.1.7.0), Oracle Internet Directory server reports duplicate attribute values in the attr_uniqueness_log table. You can scan the attr_uniqueness_log table to determine and then cleanup the duplicate values.

In earlier releases, if duplicate attribute values existed in the directory before attribute uniqueness was enabled, Oracle Internet Directory server did not report an error for these duplicate values.

During an upgrade to Oracle Internet Directory 11g Release 1 (11.1.1.7.0), data is copied to the attr_uniqueness table. During this upgrade process, duplicate values are copied the attr_uniqueness_log table and not to the attr_uniqueness table.

After a fresh installation of Oracle Internet Directory, when the attribute uniqueness is enabled existing data can also have duplicate values.

To determine which entries have duplicate attribute values, follow these steps:

  1. Get the list of duplicate attribute values using SQL*Plus. For example:

    sqlplus ods@oiddb
    spool duplicateVals.out
    select attrvalue from attr_uniqueness_log ;
    spool off
    quit
    

    When prompted, enter your Oracle Database password.

  2. For each duplicate value in duplicateVals.out, take an appropriate action, depending on your deployment.

    To find entries with duplicate values, use ldapsearch. For example:

    ldapsearch -p -D cn=orcladmin -q -b " " -s sub "attributeName=duplicateValue"
    

    For example, you can remove the duplicate value from the entry, replace the value with a new value, or delete the entry altogether.

19.3 Specifying Attribute Uniqueness Constraint Entries

Attribute uniqueness constraint entries are stored under cn=unique,cn=Common,cn=Products,cn=OracleContext.

This section describes and gives examples of rules you follow when creating attribute uniqueness constraints. It contains these topics:

To understand the examples in this section, refer to Figure 19-1.

Figure 19-1 Example of a Directory Information Tree

Description of Figure 19-1 follows
Description of "Figure 19-1 Example of a Directory Information Tree"

19.3.1 Specifying Multiple Attribute Names in an Attribute Uniqueness Constraint

When multiple attribute uniqueness constraints have different values in orcluniqueattrname, their effects are independent of each other.

For example, suppose that a user defines two attribute uniqueness constraints as follows:

Constraint1:

orcluniqueattrname: employee_id

Constraint2:

orcluniqueattrname: email_id

In this example, Constraint1 and Constraint2 enforce uniqueness on the specified attribute within their own attribute uniqueness scopes. Constraint1 and Constraint2 are independent of each other.

19.3.2 Specifying Multiple Subtrees in an Attribute Uniqueness Constraint

When multiple attribute uniqueness constraints have the same values in orcluniqueattrname, orcluniquescope and orcluniqueobjectclass, but different values in orcluniquesubtree, the subtree scopes specified by those attribute uniqueness constraints are checked individually.

For example, refer to Figure 19-1. Suppose that a user defines two attribute uniqueness constraints as follows:

Constraint1:

orcluniqueattrname: employee_id
orcluniquesubtree: o=sales, c=us, cn=root
orcluniquescope: onelevel

Constraint2:

orcluniqueattrname: employee_id
orcluniquesubtree: o=hr, c=euro, cn=root
orcluniquescope: onelevel

In this example, the attribute uniqueness on employee_id is enforced against all entries under subtree o=sales,c=us,cn=root. Attribute uniqueness on employee_id is also enforced against all entries under o=hr,c=euro,cn=root independent of the entries under the subtree o=sales,c=us,cn=root—that is, the directory server enforces the unique value of the employee_id attribute for employee3 and employee4. Unique employee_id is enforced for employee7 and employee8 as well while employee7 could have the same employee_id as employee4.

19.3.3 Specifying Multiple Scopes in an Attribute Uniqueness Constraint

When multiple attribute uniqueness constraints have the same values in orcluniqueattrname, orcluniquesubtree and orcluniqueobjectclass, but different values in orcluniquescope, the attribute uniqueness constraint with the largest search scope takes effect.

For example, referring to Figure 19-1, suppose that a user defines two attribute uniqueness constraints as follows:

Constraint1:

orcluniqueattrname: employee_id
orcluniquesubtree: c=us, cn=root
orcluniquescope: onelevel

Constraint2:

orcluniqueattrname: employee_id
orcluniquesubtree: c=us, cn=root
orcluniquescope: sub

In this example, the attribute uniqueness on employee_id is enforced against all entries under the subtree c=us,cn=root and the entry c=us,cn=root itself. Note that this is the same as if the user had defined only Constraint2.

19.3.4 Specifying Multiple Object Classes in an Attribute Uniqueness Constraint

When multiple attribute uniqueness constraints have the same values in orcluniqueattrname, orcluniquesubtree, and orcluniquescope, but different values in orcluniqueobjectclass, then the union of attributes belonging to those object classes is checked.

For example, look at Figure 19-1. Suppose that a user defines two attribute uniqueness constraints as follows:

Constraint1:

orcluniqueattrname: employee_id
orcluniquesubtree: c=us, cn=root
orcluniqueobjectclass: person

Constraint2:

orcluniqueattrname: employee_id
orcluniquesubtree: c=us, cn=root

In this example, the attribute uniqueness on employee_id is enforced against all entries under the subtree c=us,cn=root and the entry c=us,cn=root itself, no matter what object class those entries belong to. Note that Constraint2 specifies no orcluniqueobjectclass attribute, which is the same as specifying all object classes.

19.3.5 Specifying Multiple Subtrees, Scopes, and Object Classes in an Attribute Uniqueness Constraint

When multiple attribute uniqueness constraints have the same values in orcluniqueattrname, but different values in orcluniquesubtree, orcluniquescope, and orcluniqueobjectclass, the entries that belong to the attribute uniqueness scopes of different constraints are checked individually.

For example, referring to Figure 19-1, suppose that a user defines two attribute uniqueness constraints as follows:

Constraint1:

orcluniqueattrname: employee_id
orcluniquesubtree: o=sales, c=us, cn=root
orcluniquescope: onelevel
orcluniqueobjectclass: person

Constraint2:

orcluniqueattrname: employee_id
orcluniquesubtree: c=euro, cn=root
orcluniquescope: sub
orcluniqueobjectclass: organization

In this example, the attribute uniqueness on employee_id is enforced against each of the following independent of each other:

  • All entries one level under the entry o=sales,c=us,cn=root with the object class person

  • All entries under subtree c=euro,cn=root and the entry c=euro,cn=root itself with the object class organization

19.4 Managing an Attribute Uniqueness Constraint Entry by Using Oracle Directory Services Manager

You can manage an attribute uniqueness constraint policy by using Oracle Directory Services Manager.

19.4.1 Creating an Attribute Uniqueness Constraint Entry by Using ODSM

  1. Invoke Oracle Directory Services Manager and connect to the Oracle Internet Directory server as described in Section 7.4.5, "Invoking Oracle Directory Services Manager."

  2. Select Advanced from the task selection bar.

  3. Expand Attribute Uniqueness in the left pane.

  4. On the toolbar, choose the Create an attribute uniqueness constraint icon. This displays the New Constraint window.

  5. In the New Constraint dialog box, enter values in the text fields and select the Unique Attribute Scope. You can click Browse to select the Unique Attribute Subtree.

  6. If you want to enable the constraint now, click Enable Unique Attribute.

  7. Choose OK. The entry you just created appears in the list of attribute uniqueness constraint entries in the left panel.

  8. Click Apply to apply this constraint or Revert to revert to the state before you created the new entry.

19.4.2 Modifying an Attribute Uniqueness Constraint Entry by Using ODSM

  1. Invoke Oracle Directory Services Manager and connect to the Oracle Internet Directory server as described in Section 7.4.5, "Invoking Oracle Directory Services Manager."

  2. Select Advanced from the task selection bar.

  3. Expand Attribute Uniqueness in the left pane.

  4. Select an existing uniqueness constraint. This displays the General tab of the Attribute Uniqueness Constraint window.

  5. Enter or modify values.

  6. If you want to enable the constraint now, click Enable Unique Attribute.

  7. Click Apply to apply this change or Revert to revert to the state before you modified the entry.

19.4.3 Deleting an Attribute Uniqueness Constraint Entry by Using ODSM

To delete an attribute uniqueness constraint policy:

  1. Invoke Oracle Directory Services Manager and connect to the Oracle Internet Directory server as described in Section 7.4.5, "Invoking Oracle Directory Services Manager."

  2. Select Advanced from the task selection bar.

  3. Expand Attribute Uniqueness in the left pane.

  4. In the left panel, select the attribute uniqueness constraint entry you want to delete.

  5. Choose the Delete icon, then, when prompted, confirm the deletion. The entry you deleted no longer appears in the list of attribute uniqueness constraint entries in the left panel.

  6. Click Apply to apply this change or Revert to revert to the state before you deleted the entry.

19.5 Managing an Attribute Uniqueness Constraint Entry by Using the Command Line

You can manage an attribute uniqueness constraint policy by using the command line.

19.5.1 Creating Attribute Uniqueness Across a Directory by Using Command-Line Tools

To create an instance of attribute uniqueness across an entire directory, specify an attribute name for which you want to enforce value uniqueness.

For example, to make employee identifiers unique for all US employees at MyCompany, you would follow these steps:

  1. Create an attribute uniqueness constraint entry (in LDIF format) as follows:

    dn: cn=constraint1, cn=unique, cn=common, cn=products, cn=oraclecontext
    objectclass: orclUniqueConfig
    orcluniqueattrname: employeenumber
    orcluniquesubtree: o=MyCompany, c=US
    orcluniqueobjectclass: person
    
  2. Apply the attribute uniqueness feature by loading the attribute uniqueness constraint entry as follows:

    ldapadd –h host -p port -D DN -q -f constraint1.ldif
    
  3. Restart the directory server.

Example:

The following LDIF file, uniquenessConstraint.ldif, specifies a uniqueness constraint for the orclcommonusernickname attribute:

# Use this LDIF file to set up a uniqueness constraint on the nickname 
# attribute within the user search base.
# Before running the script, change the following parameters in the LDIF file.
#  <userid_attribute> -  Specify the name of the attribute that holds the user
# id. This value should be the same as the orclcommonusernickname attribute
# configured for the realm.#  <dn _f_user_serach_base> - Specify the user search base in which the
# uniqueness constraint should be enforced.
#
dn: cn=<userid_attribute> ,cn=unique,cn=common,cn=Products, cn=OracleContext
changetype: add
objectclass: orclUniqueConfig
orcluniqueattrname: <userid _ttribute>
orcluniquesubtree: <dn_of_user_search_base>
orcluniqueenable:1 

19.5.2 Creating Attribute Uniqueness Across One Subtree by Using Command-Line Tools

To create an instance of attribute uniqueness across one or more subtrees, specify:

  • An attribute name for which you want to enforce value uniqueness

  • Subtree locations under which you want the uniqueness constraint to be enforced

For example, suppose that MyCompany hosts the directories for SubscriberCompany1 and SubscriberCompany2, and you want to enforce the uniqueness of the employee identifier attribute in SubscriberCompany1 only. When you add an entry such as uid=dlin,ou=people,o=SubscriberCompany1,dc=MyCompany,
dc=com
, you must enforce uniqueness only in the o=SubscriberCompany1,dc=MyCompany,dc=com subtree. Do this by listing the DN of the subtree explicitly in the attribute uniqueness constraint configuration.

In this case, the LDIF file would look like this:

dn: cn=constraint1, cn=unique, cn=common, cn=products, cn=oraclecontext
objectclass: orclUniqueConfig
orcluniqueattrname: employeenumber
orcluniquesubtree: o=SubscriberCompany1,dc=MyCompany,     dc=com

19.5.3 Creating Attribute Uniqueness Across One Object Class by Using Command-Line Tools

To create an instance of attribute uniqueness across one object class, specify:

  • An attribute name for which you want to enforce value uniqueness

  • Object class name

In this case, the LDIF file would look like this:

dn: cn=constraint1, cn=unique, cn=common, cn=products, cn=oraclecontext
objectclass: orclUniqueConfig
orcluniqueattrname: employeenumber
orcluniqueobjectclass: person

Use ldapadd to add the entry.

ldapadd -D "cn=orcladmin" -q -p port -D user -f file_name

19.5.4 Modifying Attribute Uniqueness Constraint Entries by Using Command-Line Tools

To modify an attribute uniqueness entry, use create an LDIF file for the entry, then use ldapmodify to upload it into the directory.

For example, suppose there is an existing attribute uniqueness constraint entry:

dn: cn=constraint1, cn=unique, cn=common, cn=products, cn=oraclecontext
objectclass: orclUniqueConfig
orcluniqueattrname: employeenumber
orcluniquesubtree: o=MyCompany, c=US
orcluniqueobjectclass: person

To enforce the constraint against c=US, instead of o=MyCompany, you would perform these steps:

  1. Create an LDIF entry to change the orcluniquenesssubtree:

    dn: cn=constraint1, cn=unique, cn=common, cn=products, cn=oraclecontext
    changetype: modify
    replace: orcluniquesubtree
    orcluniquesubtree: o=Oracle Corporation, c=US
    
  2. Use ldapmodify to apply the change to directory server.

    ldapmodify -D "cn=orcladmin" -q -p port -D user -f file_name
    
  3. Restart the directory server to effect this change.

19.5.5 Deleting Attribute Uniqueness Constraint Entries by Using Command-Line Tools

Use the ldapdelete command-line tool to delete an attribute uniqueness constraint policy.

  1. Remove the attribute uniqueness constraint entry from the directory by using ldapdelete.

    ldapdelete -D "cn=orcladmin" -q -p port -D bind_DN \   
     "cn=constraint1,cn=unique,cn=common,cn=products,cn=oraclecontext"
    
  2. Restart the directory server to effect this change.

19.5.6 Enabling and Disabling Attribute Uniqueness by Using Command-Line Tools

You can enable or disable attribute uniqueness for an existing attribute uniqueness constraint entry.

To enable attribute uniqueness for an existing attribute uniqueness constraint entry:

  1. Set the orcluniqueenable attribute to 1 by using ldapmodify.

  2. Restart the directory server to enable the policy.

To disable attribute uniqueness:

  1. Set the orcluniqueenable attribute to 0 by using ldapmodify.

  2. Restart the directory server to disable the policy.