When working with LDAP sources, this is synonymous with working with DN’s. Distinguished Names (DN) identify a user’s CN (Common Name) as well as their hierarchical position in the directory. If we look at the following example below I will explain the various important LDAP attributes:
dn: cn=John Becker,dc=Contoso,dc=com
cn: John Becker
givenName: John
sn: Becker
mail: john@contoso.com
manager: cn=Sam Louis,dc=Contoso,dc=com
In the example the DN is the name of the entry; it’s not an attribute nor part of the entry. The DN forms the unique anchor for a LDAP object. No two users can have duplicate DN’s. The RDN or Relative Distinguished Name in this examples is “CN=John Becker” and “DC=Contoso,dc=com” is the DN of the parent object, where DC denotes the Domain Component. In this example the following entries are merely attributes which are not required. The CN is the user’s common name, “mail” the e-mail address and SN the surname.
It is possible for two users to have identical CN and RDN values as long as these RDN values do not exist within the same parent DN. Thus “CN=Al,OU=users,dc=net” and “CN=Al,OU=otherUsers,dc=net” are both valued users. Additionally (at least in the Active Directory world) there are two additional unique identifiers; the sAMAccountName and the UserPrincipleName. There can be no duplication of sAMAccountName or UPN within the same domain.
Determine a user’s RDN (Relative Distinguished Name)
A simple way of determining a user’s RDN is to use an Advanced Flow rule and selecting a ‘Distinguished Name’ rule. This GUI settings (under the Attribute Flow Rule configuration of the MA) allows you to set a numerical value in order to flow a DN component to another data source. The numerical value is used as such:
“CN=John Lowden,OU=users,DC=Contoso,DC=com”
1: “John Lowden”
2: “users”
3: Contoso
4: com
Retrieving a object’s RDN
In order to retrieve an object RDN, ILM provides an simple method. Find the LDAP (connectorspace object) csobject and use the RDN property.
‘Find the current LDAP object based on the current MV object being processed
Dim LdapMA as ConnectedMA = mventry.ConnectedMAs(“LDAP Source”)
csentry = adMA.Connectors.ByIndex(0)
‘Select the object RDN
Dim RDN as String = csentry.RDN
‘Select the object DN
Dim DN as String = csentry.DN.Tostring
Retrieving an object’s Domain Component
One way of retrieving an object DC (domain component) is to use a simple combination of the csentry.DN property and the ’substring’ function. We first retrieve the object DN and then search for a substring matching our domain component.
Dim MA As ConnectedMA = mventry.ConnectedMAs(“AngloCoal”)
Dim DN As String = MA.AngloCoalAD.Connectors.ByIndex(0).DN.ToString
Dim ObjectDC As String = DN.Substring(MA.Connectors.ByIndex(0).DN.ToString.IndexOf(“DC=”)).ToLower
If ObjectDC = “dc=test,dc=com” Then
…
‘ do something
…
End If
Moving an object by modifying its DN
There are always a requirements to modify or at least identify a users hierarchical position. These are mostly linked to moving users with the LDAP hierarchy when the accounts is disabled or there is a change to entitlement. ILM provides a few ways of simply and quickly determining and changing these location.
Thus, in order to change a user’s RDN or OU/CN location you will need to change the object’s DN. Based on the previous examples this is now a simple process. Have a look at the examples below:
‘Move a user to a new OU location while keeping the same RDN
Dim adMA As ConnectedMA = mventry.ConnectedMAs(“LDAP Source”)
Dim csentry As csentry = adMA.Connectors.ByIndex(0)
Dim RDN As String = csentry.RDN
Dim NewOU As String = “OU=test,DC=test,DC=com”
Dim changeLocation As String = adMA.EscapeDNComponent(RDN).Concat(NewLocation)
csentry.DN = changeLocation