当前位置: 首页>>代码示例>>Java>>正文


Java DefaultDirectoryService类代码示例

本文整理汇总了Java中org.apache.directory.server.core.DefaultDirectoryService的典型用法代码示例。如果您正苦于以下问题:Java DefaultDirectoryService类的具体用法?Java DefaultDirectoryService怎么用?Java DefaultDirectoryService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DefaultDirectoryService类属于org.apache.directory.server.core包,在下文中一共展示了DefaultDirectoryService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.apache.directory.server.core.DefaultDirectoryService; //导入依赖的package包/类
/**
 * Get's the initial context factory for the provider's ou=system context root.
 *
 * @throws Exception
 *             if there is a failure of any kind
 */
protected void setUp() throws Exception {
    setStart(getStart() + 1);
    setDirectoryService(new DefaultDirectoryService());
    getDirectoryService().setShutdownHookEnabled(false);
    setPort(AvailablePortFinder.getNextAvailable(1024));
    setLdapServer(new LdapServer());
    getLdapServer().setTransports(new TcpTransport(getPort()));
    getLdapServer().setDirectoryService(getDirectoryService());

    setupSaslMechanisms(getLdapServer());
    getDirectoryService().setWorkingDirectory(
            new File("target" + File.separator + "server-work"));
    doDelete(getDirectoryService().getWorkingDirectory());
    configureDirectoryService();
    getDirectoryService().startup();

    configureLdapServer();

    // TODO shouldn't this be before calling configureLdapServer() ???
    getLdapServer().addExtendedOperationHandler(new StartTlsHandler());
    getLdapServer().addExtendedOperationHandler(new StoredProcedureExtendedOperationHandler());

    getLdapServer().start();
    setContexts(ServerDNConstants.ADMIN_SYSTEM_DN, "secret");
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:32,代码来源:AbstractApacheDSServer.java

示例2: ApacheDSContainerWithSecurity

import org.apache.directory.server.core.DefaultDirectoryService; //导入依赖的package包/类
public ApacheDSContainerWithSecurity(String root, String ldifs) throws Exception {
	this.ldifResources = ldifs;
	service = new DefaultDirectoryService();
	List<Interceptor> list = new ArrayList<Interceptor>();

	list.add(new NormalizationInterceptor());
	list.add(new AuthenticationInterceptor());
	list.add(new ReferralInterceptor());
	// list.add( new AciAuthorizationInterceptor() );
	// list.add( new DefaultAuthorizationInterceptor() );
	list.add(new ExceptionInterceptor());
	// list.add( new ChangeLogInterceptor() );
	list.add(new OperationalAttributeInterceptor());
	// list.add( new SchemaInterceptor() );
	list.add(new SubentryInterceptor());
	// list.add( new CollectiveAttributeInterceptor() );
	// list.add( new EventInterceptor() );
	// list.add( new TriggerInterceptor() );
	// list.add( new JournalInterceptor() );

	service.setInterceptors(list);
	partition = new JdbmPartition();
	partition.setId("rootPartition");
	partition.setSuffix(root);
	this.root = root;
	service.addPartition(partition);
	service.setExitVmOnShutdown(false);
	service.setShutdownHookEnabled(false);
	service.getChangeLog().setEnabled(false);
	service.setDenormalizeOpAttrsEnabled(true);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:32,代码来源:ApacheDSContainerWithSecurity.java

示例3: InMemoryDirectoryServiceFactory

import org.apache.directory.server.core.DefaultDirectoryService; //导入依赖的package包/类
/**
 * Default constructor which creates {@link DefaultDirectoryService} instance and configures {@link AvlPartitionFactory} as
 * the {@link PartitionFactory} implementation.
 */
public InMemoryDirectoryServiceFactory() {
    try {
        directoryService = new DefaultDirectoryService();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    directoryService.setShutdownHookEnabled(false);
    partitionFactory = new AvlPartitionFactory();
}
 
开发者ID:kawasima,项目名称:bouncr,代码行数:14,代码来源:InMemoryDirectoryServiceFactory.java

示例4: ApacheDS

import org.apache.directory.server.core.DefaultDirectoryService; //导入依赖的package包/类
private ApacheDS(String realm, String baseDn) {
  this.realm = realm;
  this.baseDn = baseDn;
  directoryService = new DefaultDirectoryService();
  ldapServer = new LdapServer();
  kdcServer = new KdcServer();
}
 
开发者ID:SonarQubeCommunity,项目名称:sonar-activedirectory,代码行数:8,代码来源:ApacheDS.java

示例5: InMemoryDirectoryServiceFactory

import org.apache.directory.server.core.DefaultDirectoryService; //导入依赖的package包/类
/**
 * Default constructor which creates {@link DefaultDirectoryService} instance and configures {@link AvlPartitionFactory} as
 * the {@link PartitionFactory} implementation.
 */
public InMemoryDirectoryServiceFactory() {
   try {
      directoryService = new DefaultDirectoryService();
   } catch (Exception e) {
      throw new RuntimeException(e);
   }
   directoryService.setShutdownHookEnabled(false);
   partitionFactory = new AvlPartitionFactory();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:14,代码来源:InMemoryDirectoryServiceFactory.java

示例6: loadLdif

import org.apache.directory.server.core.DefaultDirectoryService; //导入依赖的package包/类
public static void loadLdif(DefaultDirectoryService directoryService, Resource ldifFile) throws IOException {
    File tempFile = File.createTempFile("spring_ldap_test", ".ldif");
    try {
        InputStream inputStream = ldifFile.getInputStream();
        IOUtils.copy(inputStream, new FileOutputStream(tempFile));
        LdifFileLoader fileLoader = new LdifFileLoader(directoryService.getSession(), tempFile.getAbsolutePath());
        fileLoader.execute();
    } finally {
        try {
            tempFile.delete();
        } catch (Exception e) {
            // Ignore this
        }
    }
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:16,代码来源:LdapTestUtils.java

示例7: newEmbeddedServer

import org.apache.directory.server.core.DefaultDirectoryService; //导入依赖的package包/类
public static EmbeddedLdapServer newEmbeddedServer(String defaultPartitionName, String defaultPartitionSuffix, int port)
        throws Exception{
    workingDirectory = new File(System.getProperty("java.io.tmpdir") + "/apacheds-test1");
    FileUtils.deleteDirectory(workingDirectory);

    DefaultDirectoryService directoryService = new DefaultDirectoryService();
    directoryService.setShutdownHookEnabled(true);
    directoryService.setAllowAnonymousAccess(true);

    directoryService.setWorkingDirectory(workingDirectory);
    directoryService.getChangeLog().setEnabled( false );

    JdbmPartition partition = new JdbmPartition();
    partition.setId(defaultPartitionName);
    partition.setSuffix(defaultPartitionSuffix);
    directoryService.addPartition(partition);

    directoryService.startup();

    // Inject the apache root entry if it does not already exist
    if ( !directoryService.getAdminSession().exists( partition.getSuffixDn() ) )
    {
        ServerEntry entry = directoryService.newEntry(new LdapDN(defaultPartitionSuffix));
        entry.add("objectClass", "top", "domain", "extensibleObject");
        entry.add("dc", defaultPartitionName);
        directoryService.getAdminSession().add( entry );
    }

    LdapServer ldapServer = new LdapServer();
    ldapServer.setDirectoryService(directoryService);

    TcpTransport ldapTransport = new TcpTransport(port);
    ldapServer.setTransports( ldapTransport );
    ldapServer.start();

    return new EmbeddedLdapServer(directoryService, ldapServer);
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:38,代码来源:EmbeddedLdapServer.java

示例8: getService

import org.apache.directory.server.core.DefaultDirectoryService; //导入依赖的package包/类
public DefaultDirectoryService getService() {
	return service;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:4,代码来源:ApacheDSContainerWithSecurity.java

示例9: initDirectoryService

import org.apache.directory.server.core.DefaultDirectoryService; //导入依赖的package包/类
private void initDirectoryService() throws Exception {
  ds = new DefaultDirectoryService();
  ds.setInstanceLayout(new InstanceLayout(workDir));

  CacheService cacheService = new CacheService();
  ds.setCacheService(cacheService);

  // first load the schema
  InstanceLayout instanceLayout = ds.getInstanceLayout();
  File schemaPartitionDirectory = new File(
          instanceLayout.getPartitionsDirectory(), "schema");
  SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(
          instanceLayout.getPartitionsDirectory());
  extractor.extractOrCopy();

  SchemaLoader loader = new LdifSchemaLoader(schemaPartitionDirectory);
  SchemaManager schemaManager = new DefaultSchemaManager(loader);
  schemaManager.loadAllEnabled();
  ds.setSchemaManager(schemaManager);
  // Init the LdifPartition with schema
  LdifPartition schemaLdifPartition = new LdifPartition(schemaManager);
  schemaLdifPartition.setPartitionPath(schemaPartitionDirectory.toURI());

  // The schema partition
  SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
  schemaPartition.setWrappedPartition(schemaLdifPartition);
  ds.setSchemaPartition(schemaPartition);

  JdbmPartition systemPartition = new JdbmPartition(ds.getSchemaManager());
  systemPartition.setId("system");
  systemPartition.setPartitionPath(new File(
          ds.getInstanceLayout().getPartitionsDirectory(),
          systemPartition.getId()).toURI());
  systemPartition.setSuffixDn(new Dn(ServerDNConstants.SYSTEM_DN));
  systemPartition.setSchemaManager(ds.getSchemaManager());
  ds.setSystemPartition(systemPartition);

  ds.getChangeLog().setEnabled(false);
  ds.setDenormalizeOpAttrsEnabled(true);
  ds.addLast(new KeyDerivationInterceptor());

  // create one partition
  String orgName= conf.getProperty(ORG_NAME).toLowerCase(Locale.ENGLISH);
  String orgDomain = conf.getProperty(ORG_DOMAIN).toLowerCase(Locale.ENGLISH);

  JdbmPartition partition = new JdbmPartition(ds.getSchemaManager());
  partition.setId(orgName);
  partition.setPartitionPath(new File(
          ds.getInstanceLayout().getPartitionsDirectory(), orgName).toURI());
  partition.setSuffixDn(new Dn("dc=" + orgName + ",dc=" + orgDomain));
  ds.addPartition(partition);
  // indexes
  Set<Index<?, ?, String>> indexedAttributes = new HashSet<Index<?, ?, String>>();
  indexedAttributes.add(new JdbmIndex<String, Entry>("objectClass", false));
  indexedAttributes.add(new JdbmIndex<String, Entry>("dc", false));
  indexedAttributes.add(new JdbmIndex<String, Entry>("ou", false));
  partition.setIndexedAttributes(indexedAttributes);

  // And start the ds
  ds.setInstanceId(conf.getProperty(INSTANCE));
  ds.startup();
  // context entry, after ds.startup()
  Dn dn = new Dn("dc=" + orgName + ",dc=" + orgDomain);
  Entry entry = ds.newEntry(dn);
  entry.add("objectClass", "top", "domain");
  entry.add("dc", orgName);
  ds.getAdminSession().add(entry);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:69,代码来源:MiniKdc.java

示例10: initDirectoryService

import org.apache.directory.server.core.DefaultDirectoryService; //导入依赖的package包/类
private void initDirectoryService() throws Exception {
    ds = new DefaultDirectoryService();
    ds.setInstanceLayout(new InstanceLayout(workDir));

    CacheService cacheService = new CacheService();
    ds.setCacheService(cacheService);

    // first load the schema
    InstanceLayout instanceLayout = ds.getInstanceLayout();
    File schemaPartitionDirectory = new File(instanceLayout.getPartitionsDirectory(), "schema");
    SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(instanceLayout.getPartitionsDirectory());
    extractor.extractOrCopy();

    SchemaLoader loader = new LdifSchemaLoader(schemaPartitionDirectory);
    SchemaManager schemaManager = new DefaultSchemaManager(loader);
    schemaManager.loadAllEnabled();
    ds.setSchemaManager(schemaManager);
    // Init the LdifPartition with schema
    LdifPartition schemaLdifPartition = new LdifPartition(schemaManager);
    schemaLdifPartition.setPartitionPath(schemaPartitionDirectory.toURI());

    // The schema partition
    SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
    schemaPartition.setWrappedPartition(schemaLdifPartition);
    ds.setSchemaPartition(schemaPartition);

    JdbmPartition systemPartition = new JdbmPartition(ds.getSchemaManager());
    systemPartition.setId("system");
    systemPartition.setPartitionPath(
            new File(ds.getInstanceLayout().getPartitionsDirectory(), systemPartition.getId()).toURI());
    systemPartition.setSuffixDn(new Dn(ServerDNConstants.SYSTEM_DN));
    systemPartition.setSchemaManager(ds.getSchemaManager());
    ds.setSystemPartition(systemPartition);

    ds.getChangeLog().setEnabled(false);
    ds.setDenormalizeOpAttrsEnabled(true);
    ds.addLast(new KeyDerivationInterceptor());

    // create one partition
    String orgName = conf.getProperty(ORG_NAME).toLowerCase(Locale.ENGLISH);
    String orgDomain = conf.getProperty(ORG_DOMAIN).toLowerCase(Locale.ENGLISH);

    JdbmPartition partition = new JdbmPartition(ds.getSchemaManager());
    partition.setId(orgName);
    partition.setPartitionPath(new File(ds.getInstanceLayout().getPartitionsDirectory(), orgName).toURI());
    partition.setSuffixDn(new Dn("dc=" + orgName + ",dc=" + orgDomain));
    ds.addPartition(partition);
    // indexes
    Set<Index<?, ?, String>> indexedAttributes = new HashSet<Index<?, ?, String>>();
    indexedAttributes.add(new JdbmIndex<String, Entry>("objectClass", false));
    indexedAttributes.add(new JdbmIndex<String, Entry>("dc", false));
    indexedAttributes.add(new JdbmIndex<String, Entry>("ou", false));
    partition.setIndexedAttributes(indexedAttributes);

    // And start the ds
    ds.setInstanceId(conf.getProperty(INSTANCE));
    ds.startup();
    // context entry, after ds.startup()
    Dn dn = new Dn("dc=" + orgName + ",dc=" + orgDomain);
    Entry entry = ds.newEntry(dn);
    entry.add("objectClass", "top", "domain");
    entry.add("dc", orgName);
    ds.getAdminSession().add(entry);
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:65,代码来源:MiniKdc.java

示例11: initDirectoryService

import org.apache.directory.server.core.DefaultDirectoryService; //导入依赖的package包/类
/**
 * Initialize the server. It creates the partition, injects the context
 * entries for the created partitions, and loads an LDIF file (
 * {@link #ldifLoadFile}) for initial entries.
 *
 * @param workDir
 *          the directory to be used for storing the data
 * @throws Exception
 *           if there were some problems while initializing the system
 */
private void initDirectoryService(File workDir) throws Exception {
  // Initialize the LDAP service
  service = new DefaultDirectoryService();
  service.setWorkingDirectory(workDir);

  // first load the schema
  initSchemaPartition();

  // then the system partition
  // this is a MANDATORY partition
  Partition systemPartition = addPartition("system",
      ServerDNConstants.SYSTEM_DN);
  service.setSystemPartition(systemPartition);

  // create the partition for testing
  Partition testingPartition = addPartition("ldapTesting",
      "ou=ldapTesting,dc=pune,dc=gemstone,dc=com");

  // Disable the shutdown hook
  service.setShutdownHookEnabled(false);
  // Disable the ChangeLog system
  service.getChangeLog().setEnabled(false);
  service.setDenormalizeOpAttrsEnabled(true);

  // And start the service
  service.startup();

  // inject the entry for testing
  if (!service.getAdminSession().exists(testingPartition.getSuffixDn())) {
    DN dnTesting = new DN("ou=ldapTesting,dc=pune,dc=gemstone,dc=com");
    ServerEntry entryTesting = service.newEntry(dnTesting);
    entryTesting.add("objectClass", "top", "domain", "extensibleObject");
    entryTesting.add("dc", "pune");
    service.getAdminSession().add(entryTesting);
  }

  // load schema from LDIF
  if (ldifLoadFile != null) {
    LdifFileLoader ldifLoader = new LdifFileLoader(
        service.getAdminSession(), ldifLoadFile);
    int numLoaded = ldifLoader.execute();
    if (numLoaded <= 0) {
      throw new Exception(
          "Failed to load any entries from " + ldifLoadFile);
    } else {
      System.out.println(
          "LDAP loaded " + numLoaded + " entries from " + ldifLoadFile);
    }
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:61,代码来源:LdapTestServer.java

示例12: initDirectoryService

import org.apache.directory.server.core.DefaultDirectoryService; //导入依赖的package包/类
/**
 * Initialize the server. It creates the partition, adds the index, and
 * injects the context entries for the created partitions.
 *
 * @param workDir the directory to be used for storing the data
 * @throws Exception if there were some problems while initializing
 */
private void initDirectoryService(final ServletContext servletContext,
        final File workDir)
        throws Exception {

    // Initialize the LDAP service
    service = new DefaultDirectoryService();
    service.setWorkingDirectory(workDir);

    // first load the schema
    initSchemaPartition(servletContext);

    // then the system partition
    // this is a MANDATORY partition
    Partition systemPartition = addPartition("system",
            ServerDNConstants.SYSTEM_DN);
    service.setSystemPartition(systemPartition);

    // Disable the ChangeLog system
    service.getChangeLog().setEnabled(false);
    service.setDenormalizeOpAttrsEnabled(true);

    // Now we can create as many partitions as we need
    Partition ispPartition = addPartition("isp", "o=isp");
    addIndex(ispPartition, "objectClass", "ou", "uid");

    // And start the service
    service.startup();

    // Inject the foo root entry if it does not already exist
    try {
        service.getAdminSession().lookup(ispPartition.getSuffixDn());
    } catch (LdapException lnnfe) {
        DN dnIsp = new DN("o=isp");
        ServerEntry rootEntry = service.newEntry(dnIsp);
        rootEntry.add("objectClass", "top", "organization");
        rootEntry.add("o", "isp");
        service.getAdminSession().add(rootEntry);

        DN dnPeople = new DN("ou=People,o=isp");
        ServerEntry peopleEntry = service.newEntry(dnPeople);
        peopleEntry.add("objectClass", "top", "organizationalUnit");
        peopleEntry.add("ou", "People");
        service.getAdminSession().add(peopleEntry);
    }
}
 
开发者ID:ilgrosso,项目名称:oldSyncopeIdM,代码行数:53,代码来源:ApacheDSStartStopListener.java

示例13: initDirectoryService

import org.apache.directory.server.core.DefaultDirectoryService; //导入依赖的package包/类
/**
 * Initialize the server. It creates the partition, adds the index, and injects the context entries for the created
 * partitions.
 *
 * @param workDir the directory to be used for storing the data
 * @param loadDefaultContent if default content should be loaded
 * @throws Exception if there were some problems while initializing
 */
private void initDirectoryService(final ServletContext servletContext, final File workDir,
        final boolean loadDefaultContent) throws Exception {

    // Initialize the LDAP service
    service = new DefaultDirectoryService();
    service.setInstanceLayout(new InstanceLayout(workDir));

    CacheService cacheService = new CacheService();
    cacheService.initialize(service.getInstanceLayout());

    service.setCacheService(cacheService);

    // first load the schema
    initSchemaPartition();

    // then the system partition
    // this is a MANDATORY partition
    // DO NOT add this via addPartition() method, trunk code complains about duplicate partition
    // while initializing
    JdbmPartition systemPartition = new JdbmPartition(service.getSchemaManager(), service.getDnFactory());
    systemPartition.setId("system");
    systemPartition.setPartitionPath(
            new File(service.getInstanceLayout().getPartitionsDirectory(), systemPartition.getId()).toURI());
    systemPartition.setSuffixDn(new Dn(ServerDNConstants.SYSTEM_DN));
    systemPartition.setSchemaManager(service.getSchemaManager());

    // mandatory to call this method to set the system partition
    // Note: this system partition might be removed from trunk
    service.setSystemPartition(systemPartition);

    // Disable the ChangeLog system
    service.getChangeLog().setEnabled(false);
    service.setDenormalizeOpAttrsEnabled(true);

    // Now we can create as many partitions as we need
    Partition ispPartition = addPartition("isp", "o=isp", service.getDnFactory());

    // Index some attributes on the apache partition
    addIndex(ispPartition, "objectClass", "ou", "uid");

    // And start the service
    service.startup();

    if (loadDefaultContent) {
        Resource contentLdif = WebApplicationContextUtils.getWebApplicationContext(servletContext).
                getResource("classpath:/content.ldif");
        LdifInputStreamLoader contentLoader = new LdifInputStreamLoader(service.getAdminSession(),
                contentLdif.getInputStream());
        int numEntries = contentLoader.execute();
        LOG.info("Successfully created {} entries", numEntries);
    }
}
 
开发者ID:apache,项目名称:syncope,代码行数:61,代码来源:ApacheDSStartStopListener.java

示例14: initDirectoryService

import org.apache.directory.server.core.DefaultDirectoryService; //导入依赖的package包/类
private void initDirectoryService() throws Exception {
  ds = new DefaultDirectoryService();
  ds.setInstanceLayout(new InstanceLayout(workDir));

  CacheService cacheService = new CacheService();
  ds.setCacheService(cacheService);

  // first load the schema
  InstanceLayout instanceLayout = ds.getInstanceLayout();
  File schemaPartitionDirectory = new File(
          instanceLayout.getPartitionsDirectory(), "schema");
  SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(
          instanceLayout.getPartitionsDirectory());
  extractor.extractOrCopy();

  SchemaLoader loader = new LdifSchemaLoader(schemaPartitionDirectory);
  SchemaManager schemaManager = new DefaultSchemaManager(loader);
  schemaManager.loadAllEnabled();
  ds.setSchemaManager(schemaManager);
  // Init the LdifPartition with schema
  LdifPartition schemaLdifPartition = new LdifPartition(schemaManager);
  schemaLdifPartition.setPartitionPath(schemaPartitionDirectory.toURI());

  // The schema partition
  SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
  schemaPartition.setWrappedPartition(schemaLdifPartition);
  ds.setSchemaPartition(schemaPartition);

  JdbmPartition systemPartition = new JdbmPartition(ds.getSchemaManager());
  systemPartition.setId("system");
  systemPartition.setPartitionPath(new File(
          ds.getInstanceLayout().getPartitionsDirectory(),
          systemPartition.getId()).toURI());
  systemPartition.setSuffixDn(new Dn(ServerDNConstants.SYSTEM_DN));
  systemPartition.setSchemaManager(ds.getSchemaManager());
  ds.setSystemPartition(systemPartition);

  ds.getChangeLog().setEnabled(false);
  ds.setDenormalizeOpAttrsEnabled(true);
  ds.addLast(new KeyDerivationInterceptor());

  // create one partition
  String orgName= conf.getProperty(ORG_NAME).toLowerCase();
  String orgDomain = conf.getProperty(ORG_DOMAIN).toLowerCase();

  JdbmPartition partition = new JdbmPartition(ds.getSchemaManager());
  partition.setId(orgName);
  partition.setPartitionPath(new File(
          ds.getInstanceLayout().getPartitionsDirectory(), orgName).toURI());
  partition.setSuffixDn(new Dn("dc=" + orgName + ",dc=" + orgDomain));
  ds.addPartition(partition);
  // indexes
  Set<Index<?, ?, String>> indexedAttributes = new HashSet<Index<?, ?, String>>();
  indexedAttributes.add(new JdbmIndex<String, Entry>("objectClass", false));
  indexedAttributes.add(new JdbmIndex<String, Entry>("dc", false));
  indexedAttributes.add(new JdbmIndex<String, Entry>("ou", false));
  partition.setIndexedAttributes(indexedAttributes);

  // And start the ds
  ds.setInstanceId(conf.getProperty(INSTANCE));
  ds.startup();
  // context entry, after ds.startup()
  Dn dn = new Dn("dc=" + orgName + ",dc=" + orgDomain);
  Entry entry = ds.newEntry(dn);
  entry.add("objectClass", "top", "domain");
  entry.add("dc", orgName);
  ds.getAdminSession().add(entry);
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:69,代码来源:MiniKdc.java

示例15: initDirectoryService

import org.apache.directory.server.core.DefaultDirectoryService; //导入依赖的package包/类
/**
 * Initialize the server. It creates the partition, adds the index, and
 * injects the context entries for the created partitions.
 *
 * @param workDir the directory to be used for storing the data
 * @throws Exception if there were some problems while initializing the system
 */
private void initDirectoryService(File workDir) throws Exception {
  // Initialize the LDAP service
  service = new DefaultDirectoryService();
  service.setWorkingDirectory(workDir);

  // first load the schema
  initSchemaPartition();

  // then the system partition
  // this is a MANDATORY partition
  Partition systemPartition = addPartition("system", ServerDNConstants.SYSTEM_DN);
  service.setSystemPartition(systemPartition);

  // Disable the ChangeLog system
  service.getChangeLog().setEnabled(false);
  service.setDenormalizeOpAttrsEnabled(true);

  // Now we can create as many partitions as we need
  // Create some new partitions named 'foo', 'bar' and 'apache'.
  Partition fooPartition = addPartition("foo", "dc=foo,dc=com");

  // Index some attributes on the apache partition
  addIndex(fooPartition, "objectClass", "ou", "uid");

  // And start the service
  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);

}
 
开发者ID:vert-x3,项目名称:vertx-auth,代码行数:48,代码来源:EmbeddedADS.java


注:本文中的org.apache.directory.server.core.DefaultDirectoryService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。