private static void addObjectClasses(ServerEntry serverEntry, List<String> objectClasses) throws DirectoryServerException { for (String objectClass : objectClasses) { try { serverEntry.add("objectClass", objectClass); } catch (LdapException e) { throwDirectoryServerException("Could not add class to partition " + serverEntry.getDn().getName(), e); } } }
public EntryAttribute put( String upId, AttributeType attributeType, Value<?>... values ) throws LdapException { return clonedEntry.put( upId, attributeType, values ); }
public EntryAttribute get( AttributeType attributeType ) { return clonedEntry.get( attributeType ); }
private void addPartitionAttributes(String partitionDN, List<String> objectClasses, String realm, String dc) throws DirectoryServerException { try { DN adminDN = new DN(partitionDN); ServerEntry serverEntry = this.directoryService.newEntry(adminDN); addObjectClasses(serverEntry, objectClasses); serverEntry.add("o", realm); if (dc == null) { logger.warn("Domain component not found for partition with DN - " + partitionDN + ". Not setting domain component."); } else { serverEntry.add("dc", dc); } addAccessControlAttributes(serverEntry); this.directoryService.getAdminSession().add(serverEntry); } catch (Exception e) { String msg = "Could not add partition attributes for partition - " + partitionDN; throwDirectoryServerException(msg, e); } }
throw new Exception( I18n.err( I18n.ERR_215 ) ); String modsOid = schemaManager.getAttributeTypeRegistry().getOidByName( mods.getId() ); objectClassIdx.drop( value.getString(), id ); ( ( AvlIndex ) index ).add( value.get(), id ); AttributeType type = schemaManager.lookupAttributeTypeRegistry( modsOid ); entry.add( type, value ); addAliasIndices( id, new DN( ndnStr ), mods.getString() );
throw new Exception( I18n.err( I18n.ERR_215 ) ); String modsOid = schemaManager.getAttributeTypeRegistry().getOidByName( mods.getId() ); objectClassIdx.add( value.getString(), id ); ( ( AvlIndex<Object, E> ) index ).add( value.get(), id ); if ( mods.size() > 0 ) entry.put( mods ); entry.remove( mods ); if ( modsOid.equals( aliasAttributeOid ) && mods.size() > 0 ) addAliasIndices( id, new DN( ndnStr ), mods.getString() );
service.setWorkingDirectory(workDir); service.setSystemPartition(systemPartition); service.getChangeLog().setEnabled(false); service.setDenormalizeOpAttrsEnabled(true); service.startup(); DN dnFoo = new DN("dc=foo,dc=com"); ServerEntry entryFoo = service.newEntry(dnFoo); entryFoo.add("objectClass", "top", "domain", "extensibleObject"); entryFoo.add("dc", "foo"); service.getAdminSession().add(entryFoo); DN usersDN=new DN("ou=users,dc=foo,dc=com"); ServerEntry usersEntry=service.newEntry(usersDN); usersEntry.add("objectClass","organizationalUnit","top"); usersEntry.add("ou","users"); service.getAdminSession().add(usersEntry);
throw new Exception( I18n.err( I18n.ERR_215 ) ); DN normName = entry.getDn(); if ( normName.getNormName().equals( suffixDn.getNormName() ) ) throw new LdapNoSuchObjectException( I18n.err( I18n.ERR_216, parentDn ) ); EntryAttribute objectClass = entry.get( OBJECT_CLASS_AT ); String msg = I18n.err( I18n.ERR_217, normName.getName(), entry ); throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION, msg ); objectClassIdx.add( value.getString(), id ); if ( objectClass.contains( SchemaConstants.ALIAS_OC ) ) EntryAttribute aliasAttr = entry.get( ALIASED_OBJECT_NAME_AT ); addAliasIndices( id, normName, aliasAttr.getString() ); EntryAttribute entryCsn = entry.get( SchemaConstants.ENTRY_CSN_AT ); entryCsnIdx.add( entryCsn.getString(), id ); EntryAttribute entryUuid = entry.get( SchemaConstants.ENTRY_UUID_AT ); idx.add( value.get(), id );
throw new Exception( I18n.err( I18n.ERR_215 ) ); String modsOid = schemaManager.getAttributeTypeRegistry().getOidByName( mods.getId() ); objectClassIdx.drop( value.getString(), id ); ( ( AvlIndex ) index ).drop( value.get(), id ); AttributeType attrType = schemaManager.lookupAttributeTypeRegistry( modsOid ); if ( mods.size() == 0 ) entry.removeAttributes( attrType ); EntryAttribute entryAttr = entry.get( attrType ); entryAttr.remove( ( String ) value.get() ); if ( entryAttr.size() == 0 ) entry.removeAttributes( entryAttr.getId() );
ServerEntry targetEntry = ( ServerEntry ) entry.clone(); ModificationOperation modOp = mod.getOperation(); String id = mod.getAttribute().getId(); AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( id ); targetEntry.put( mod.getAttribute() ); break; EntryAttribute toBeRemoved = mod.getAttribute(); if ( toBeRemoved.size() == 0 ) targetEntry.removeAttributes( id ); EntryAttribute existing = targetEntry.get( id ); existing.remove( value ); EntryAttribute combined = new DefaultServerAttribute( id, attributeType ); EntryAttribute toBeAdded = mod.getAttribute(); EntryAttribute existing = entry.get( id ); targetEntry.put( combined ); break; throw new IllegalStateException( I18n.err( I18n.ERR_464, modOp ) );
partition.setId("apiman"); partition.setPartitionDir(partitionDirectory); partition.setSchemaManager(service.getSchemaManager()); partition.setSuffix("o=apiman"); service.addPartition(partition); service.getAdminSession().lookup(partition.getSuffixDn()); } catch (Exception lnnfe) { DN dn = new DN("o=apiman"); ServerEntry entry = service.newEntry(dn); entry.add("objectClass", "top", "domain", "extensibleObject"); entry.add("dc", "apiman"); entry.add("cn", "o=apiman"); service.getAdminSession().add(entry);
public void rename( DN dn, RDN newRdn, boolean deleteOldRdn ) throws Exception Long id = getEntryId( dn.getNormName() ); ServerEntry entry = lookup( id ); DN updn = entry.getDn(); Object newNormValue = newAtav.getNormValue().get(); AttributeType newRdnAttrType = schemaManager.lookupAttributeTypeRegistry( newNormType ); entry.add( newRdnAttrType, newAtav.getUpValue() ); RDN oldRdn = updn.getRdn(); for ( AVA oldAtav : oldRdn ) String oldNormValue = oldAtav.getNormValue().getString(); AttributeType oldRdnAttrType = schemaManager.lookupAttributeTypeRegistry( oldNormType ); entry.remove( oldRdnAttrType, oldNormValue ); DN newUpdn = ( DN ) updn.clone(); // copy da old updn newUpdn.remove( newUpdn.size() - 1 ); // remove old upRdn newUpdn.add( newRdn.getName() ); // add da new upRdn newUpdn.normalize( schemaManager.getNormalizerMapping() ); entry.setDn( newUpdn ); master.put( id, entry );
public ServerEntry createUserEntry(DN dn) { ServerEntry userEntry = m_EntryCache.get(dn.getName()); if (userEntry == null) { try { RDN rdn = dn.getRdn(2); String user = rdn.getNormValue(); dn ); userEntry.put(SchemaConstants.OBJECT_CLASS, SchemaConstants.INET_ORG_PERSON_OC); userEntry.put(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, SchemaConstants.ORGANIZATIONAL_PERSON_OC, SchemaConstants.PERSON_OC, SchemaConstants.INET_ORG_PERSON_OC); userEntry.put(SchemaConstants.CN_AT, u.getDisplayName()); userEntry.put(SchemaConstants.UID_AT,user); userEntry.put("mail", u.getEmailAddress()); userEntry.put("givenname", u.getFirstName()); userEntry.put(SchemaConstants.SN_AT, u.getLastName()); userEntry.put(SchemaConstants.OU_AT, "users"); DN mdn = new DN(String.format("cn=%s,%s", g, CROWD_GROUPS_DN)); userEntry.add("memberof", mdn.getName()); for (String g : groups) { DN mdn = new DN(String.format("cn=%s,%s", g, CROWD_GROUPS_DN)); userEntry.add("memberof", mdn.getName());
public void modify( DN dn, ModificationOperation modOp, ServerEntry mods ) throws Exception { if ( mods instanceof ClonedServerEntry ) { throw new Exception( I18n.err( I18n.ERR_215 ) ); } Long id = getEntryId( dn.getNormName() ); ServerEntry entry = ( ServerEntry ) master.get( id ); for ( AttributeType attributeType : mods.getAttributeTypes() ) { EntryAttribute attr = mods.get( attributeType ); switch ( modOp ) { case ADD_ATTRIBUTE: add( id, entry, attr ); break; case REMOVE_ATTRIBUTE: remove( id, entry, attr ); break; case REPLACE_ATTRIBUTE: replace( id, entry, attr ); break; default: throw new Exception( I18n.err( I18n.ERR_221 ) ); } } master.put( id, entry ); }
DN crowdDN = new DN(m_Suffix); crowdDN.normalize( m_SchemaManager.getRegistries().getAttributeTypeRegistry() .getNormalizerMapping() ); RDN rdn = crowdDN.getRdn(); crowdDN ); dcEntry.put(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, SchemaConstants.DOMAIN_OC); dcEntry.put(SchemaConstants.DC_AT, rdn.getUpValue().toString()); dcEntry.put("description", "Crowd Domain"); m_CrowdEntry = dcEntry; groupDn ); groupEntry.put(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, SchemaConstants.ORGANIZATIONAL_UNIT_OC); groupEntry.put(SchemaConstants.OU_AT, "groups"); groupEntry.put("description", "Crowd Groups"); m_CrowdGroupsEntry = groupEntry; usersDn ); usersEntry.put(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, SchemaConstants.ORGANIZATIONAL_UNIT_OC); usersEntry.put(SchemaConstants.OU_AT, "users"); usersEntry.put("description", "Crowd Users"); m_CrowdUsersEntry = usersEntry;
return true; } else { int dnSize = dn.size(); m_EntryCache.put(dn.getName(), m_CrowdEntry); return true; } else { m_EntryCache.put(dn.getName(), m_CrowdGroupsEntry); return true; } else if (isCrowdUsers(dn)) { DN prefix = dn.getPrefix(2); try { prefix.normalize(m_SchemaManager.getNormalizerMapping()); } catch (Exception ex) { log.error("hasEntry()", ex); } else { log.debug("Prefix is neither users nor groups"); log.debug("Crowd Users = " + m_CrowdUsersEntry.getDn()); log.debug("Crowd Groups = " + m_CrowdGroupsEntry.getDn().toString()); return false;
String name = dn.getRdn(0).getNormValue(); log.debug("Name=" + name); if("crowd".equals(name)) { log.debug("findOneLevel()::dn=" + dn.getName() + "::entry=" + se.toString() + "::filter=" + ctx.getFilter().toString()); if (dn.getName().equals(m_CrowdEntry.getDn().getName())) { return new BaseEntryFilteringCursor( new ListCursor<ServerEntry>(m_CrowdOneLevelList), if (dn.getName().equals(m_CrowdGroupsEntry.getDn().getName())) { if (dn.getName().equals(m_CrowdUsersEntry.getDn().getName())) {
private final void injectNames( List<String> names, ServerEntry entry, SchemaManager schemaManager ) throws LdapException { if ( ( names == null ) || ( names.size() == 0 ) ) { return; } EntryAttribute attr = new DefaultServerAttribute( schemaManager.lookupAttributeTypeRegistry( MetaSchemaConstants.M_NAME_AT ) ); for ( String name:names ) { attr.add( name ); } entry.put( attr ); }
public void add( AttributeType attributeType, String... values ) throws LdapException { clonedEntry.add( attributeType, values ); }