title: How to add an attribute to an LDAP schema
body: <p>I am trying to add a new attribute named sAMAccountName to an already existing LDAP schema definition which is read by <a href="https://github.com/inbloom/ldap-in-memory" rel="nofollow noreferrer">IM-LDAP</a> using <a href="https://www.ldap.com/unboundid-ldap-sdk-for-java" rel="nofollow noreferrer">UnboundID LDAP SDK</a>.</p>
  
  <p>I have added an attributeTypes entry and sAMAccountName to matchingRuleUse.</p>
  
  <pre><code>attributeTypes: ( 2.5.18.11 NAME 'sAMAccountName' DESC 'MS Sec Principal User' EQUALITY distinguishedNameMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )
  
  matchingRuleUse: ( 2.5.13.1 NAME 'distinguishedNameMatch' APPLIES ( creatorsName $ ... $ sAMAccountName ) )
  </code></pre>
  
  <p>For every previously existing attribute a call to <code>com.unboundid.ldap.sdk.schema.Schema.getAttributeType("attrName")</code> returns the attribute type. But not for my new attribute.</p>
  
  <p>What am I missing?</p>
  
  <p><strong>Edited 10/11/18 after @jwilleke comment</strong>:</p>
  
  <p>What I am trying to achieve is a mock using <a href="https://github.com/inbloom/ldap-in-memory" rel="nofollow noreferrer">IM-LDAP</a> for a very limited functionality of an Active Directory server.</p>
  
  <p>In the actual AD production environment, there are entries representing users with objectClass: person, organizationalPerson,simulatedMicrosoftSecurityPrincipal.</p>
  
  <p>In AD these entries contain sAMAccountName and memberof attributes.
  But they are not there in the schema that comes with IM-LDAP.</p>
  
  <p>The authentication Java code first performs a search on</p>
  
  <pre><code>(&amp;(objectClass=user)(sAMAccountName=userAccountName)
  </code></pre>
  
  <p>Then if an entry in found, it checks whether a given security group name is present in the multivalued attribute memberof.</p>
  
  <p>An entry exported from the production AD server looks like this :</p>
  
  <pre><code>dn: cn=Smith\,John,ou=User Accounts,dc=ACME,dc=CORE,dc=INT
  changetype: add
  objectClass: person
  objectClass: organizationalPerson
  objectClass: simulatedMicrosoftSecurityPrincipal
  cn: Smith,John
  sn: JohnS
  sAMAccountName: JohnS
  userPassword: johnspasswd
  memberof: ou=Service Accounts,dc=ACME,dc=CORE,dc=INT
  </code></pre>
  
  <p>The two new attributes are added to objectClass simulatedMicrosoftSecurityPrincipal in the schema by adding:</p>
  
  <pre><code>objectClasses: ( 2.5.6.24 NAME 'simulatedMicrosoftSecurityPrincipal' DESC 'MSSecurityPrincipal' SUP top AUXILIARY MUST sAMAccountName MAY memberof )
  </code></pre>
  
  <p>But when I try to import these entries into the LDAP mock I get an error telling me that sAMAccountName and memberof are not defined.</p>
  
  <p><strong>EDIT 2</strong>:</p>
  
  <pre><code>attributeTypes: ( 1.2.840.113556.1.4.221 NAME 'sAMAccountName' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' SINGLE-VALUE )
  </code></pre>
  
  <p>Wokrked for adding sAMAccountName, but still trying to figure out how to add memeberOf</p>
  
  <p><strong><a href="http://www.knowgate.com/shared/ldap-schema.ldif" rel="nofollow noreferrer">Here</a></strong> is the complete .ldif file.</p>