public SubentryUtils( DirectoryService directoryService ) { this.directoryService = directoryService; this.schemaManager = directoryService.getSchemaManager(); }
@Override public SchemaManager getSchemaManager() { return wrapped.getSchemaManager(); }
public void setDirectoryService( DirectoryService directoryService ) { this.directoryService = directoryService; this.schemaManager = directoryService.getSchemaManager(); this.session = directoryService.getAdminSession(); }
/** * A helper method which tells if a schema is loaded. * * @param service The Directory Service * @param schemaName The schema to check * @return <tt>true</tt> if the schema is loaded */ public static boolean isLoaded( DirectoryService service, String schemaName ) { Schema schema = service.getSchemaManager().getLoadedSchema( schemaName ); return ( schema != null ); }
private Partition createPartition(final DnFactory dnFactory, final String partitionId, final String partitionDn, File workingDirectory) throws Exception { return partitionFactory.createPartition(service.getSchemaManager(), dnFactory, partitionId, partitionDn, CACHE_SIZE, workingDirectory); }
public static CoreSession getCoreSession( String principalDn, DirectoryService service, String dn ) throws LdapException { if ( principalDn == null ) { principalDn = ""; } Dn userDn = new Dn( service.getSchemaManager(), principalDn ); LdapPrincipal principal = new LdapPrincipal( service.getSchemaManager(), userDn, AuthenticationLevel.SIMPLE ); CoreSession session = service.getSession( principal ); return session; }
/** * A helper method which tells if a schema is disabled. * * @param service The Directory Service * @param schemaName The name of the Schema to check * @return <tt>true</tt> if the schema is enabled */ public static boolean isDisabled( DirectoryService service, String schemaName ) { Schema schema = service.getSchemaManager().getLoadedSchema( schemaName ); return ( schema == null ) || schema.isDisabled(); }
/** * Creates a new instance of CramMd5CallbackHandler. * * @param ldapSession the mina IoSession * @param adminSession the admin session * @param bindRequest the bind message */ public CramMd5CallbackHandler( LdapSession ldapSession, CoreSession adminSession, BindRequest bindRequest ) { super( adminSession.getDirectoryService(), bindRequest ); this.ldapSession = ldapSession; this.adminSession = adminSession; schemaManager = adminSession.getDirectoryService().getSchemaManager(); }
/** * Creates a new instance of DigestMd5CallbackHandler. * * @param ldapSession the mina IoSession * @param adminSession the admin session * @param bindRequest the bind message */ public DigestMd5CallbackHandler( LdapSession ldapSession, CoreSession adminSession, BindRequest bindRequest ) { super( adminSession.getDirectoryService(), bindRequest ); this.ldapSession = ldapSession; this.adminSession = adminSession; schemaManager = adminSession.getDirectoryService().getSchemaManager(); }
/** * This method does nothing by default. * * @param directoryService The DirectoryService instance * @throws LdapException If the initialization failed */ public void init( DirectoryService directoryService ) throws LdapException { // Initialize the fields that will be used by all the interceptors this.directoryService = directoryService; schemaManager = directoryService.getSchemaManager(); dnFactory = directoryService.getDnFactory(); finalInterceptor.init( directoryService ); }
public LdapClassLoader( DirectoryService directoryService ) throws LdapException { super( LdapClassLoader.class.getClassLoader() ); this.directoryService = directoryService; defaultSearchDn = directoryService.getDnFactory().create( DEFAULT_SEARCH_CONTEXTS_CONFIG ); objectClassAT = directoryService.getSchemaManager().getAttributeType( SchemaConstants.OBJECT_CLASS_AT ); }
/** * The init method will initialize the local variables and load the * entryDeleted AttributeType. */ @Override public void init( DirectoryService directoryService ) throws LdapException { super.init( directoryService ); changeLog = directoryService.getChangeLog(); entryDeleted = directoryService.getSchemaManager() .getAttributeType( ApacheSchemaConstants.ENTRY_DELETED_AT_OID ); }
private Cursor<Entry> search(final CoreSession session, final String dn, final String filter) throws LdapException { try { return session.search(new Dn(dn), SearchScope.SUBTREE, FilterParser.parse(service.getSchemaManager(), filter), AliasDerefMode.NEVER_DEREF_ALIASES); } catch (final ParseException e) { throw new LdapInvalidSearchFilterException(e.getMessage()); } }
public PersistentSearchListener( LdapSession session, SearchRequest req ) { this.session = session; this.req = req; req.addAbandonListener( this ); this.psearchControl = ( PersistentSearch ) req.getControls().get( PersistentSearch.OID ); filterCtx = new LookupOperationContext( session.getCoreSession(), req.getAttributes().toArray( Strings.EMPTY_STRING_ARRAY ) ); schemaManager = session.getCoreSession().getDirectoryService().getSchemaManager(); }
private Partition createPartition(String id, String suffix) throws LdapInvalidDnException { Partition partition = new AvlPartition(service.getSchemaManager()); partition.setId(id); partition.setSuffixDn(new Dn(suffix)); return partition; }
private void importLdif(LdifReader ldifReader) throws Exception { try { for (LdifEntry ldifEntry : ldifReader) { checkPartition(ldifEntry); System.out.print(ldifEntry.toString()); directoryService.getAdminSession() .add(new DefaultEntry(directoryService.getSchemaManager(), ldifEntry.getEntry())); } } finally { IOUtils.closeQuietly(ldifReader); } }
private static void enabledPosixSchema( DirectoryService service ) throws LdapException { service.getSchemaManager().getLoadedSchema( "nis" ).enable(); service.getAdminSession().modify( new Dn( "cn=nis,ou=schema" ), new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, "m-disabled", "FALSE" ) ); }
private static void enabledPosixSchema( DirectoryService service ) throws LdapException { service.getSchemaManager().getLoadedSchema( "nis" ).enable(); service.getAdminSession().modify( new Dn( "cn=nis,ou=schema" ), new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, "m-disabled", "FALSE" ) ); }
protected List<LdifEntry> loadLdif(LdifReader ldifReader) throws Exception { List<LdifEntry> entries = new ArrayList<LdifEntry>(); for (LdifEntry ldifEntry : ldifReader) { Dn dn = ldifEntry.getDn(); if (ldifEntry.isEntry()) { org.apache.directory.api.ldap.model.entry.Entry items = ldifEntry.getEntry(); rootDSE.add(new DefaultEntry(directoryService.getSchemaManager(), items)); LOG.info("Added entry {}", dn); entries.add(ldifEntry); } } return entries; }
public synchronized void createPrincipal(String principal, String password) throws Exception { String baseDn = getKdcServer().getSearchBaseDn(); String content = "dn: uid=" + principal + "," + baseDn + "\n" + "objectClass: top\n" + "objectClass: person\n" + "objectClass: inetOrgPerson\n" + "objectClass: krb5principal\n" + "objectClass: krb5kdcentry\n" + "cn: " + principal + "\n" + "sn: " + principal + "\n" + "uid: " + principal + "\n" + "userPassword: " + password + "\n" // using businessCategory as a proxy for memberoOf attribute pending: https://issues.apache.org/jira/browse/DIRSERVER-1844 + "businessCategory: " + "cn=admins,ou=system" + "\n" + "businessCategory: " + "cn=bees,ou=system" + "\n" + "krb5PrincipalName: " + principal + "@" + getRealm() + "\n" + "krb5KeyVersionNumber: 0"; for (LdifEntry ldifEntry : new LdifReader(new StringReader(content))) { service.getAdminSession().add(new DefaultEntry(service.getSchemaManager(), ldifEntry.getEntry())); } }