コード例 #1
0
        /// <summary>
        /// Add a new partition to the server
        /// </summary>
        /// <param name="partitionId"> The partition Id </param>
        /// <param name="partitionDn"> The partition DN </param>
        /// <param name="dnFactory"> the DN factory </param>
        /// <returns> The newly added partition </returns>
        /// <exception cref="Exception"> If the partition can't be added </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected org.apache.directory.server.core.api.partition.Partition addPartition(String partitionId, String partitionDn, org.apache.directory.server.core.api.DnFactory dnFactory) throws Exception
        protected internal virtual Partition addPartition(string partitionId, string partitionDn, DnFactory dnFactory)
        {
            // Create a new partition with the given partition id
            JdbmPartition partition = new JdbmPartition(service.SchemaManager, dnFactory);

            partition.Id            = partitionId;
            partition.PartitionPath = (new File(service.InstanceLayout.PartitionsDirectory, partitionId)).toURI();
            partition.SuffixDn      = new Dn(partitionDn);
            service.addPartition(partition);

            return(partition);
        }
コード例 #2
0
        /// <summary>
        /// Initialize the server. It creates the partition, adds the index, and
        /// injects the context entries for the created partitions.
        /// </summary>
        /// <exception cref="Exception"> if there were some problems while initializing the system </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected void initializeDirectory() throws Exception
        protected internal virtual void initializeDirectory()
        {
            workingDirectory.mkdirs();

            service = new DefaultDirectoryService();
            InstanceLayout il = new InstanceLayout(workingDirectory);

            service.InstanceLayout = il;

            CacheService cacheService = new CacheService();

            cacheService.initialize(service.InstanceLayout);
            service.CacheService = cacheService;

            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.SchemaManager, service.DnFactory);

            systemPartition.Id            = "system";
            systemPartition.PartitionPath = (new File(service.InstanceLayout.PartitionsDirectory, systemPartition.Id)).toURI();
            systemPartition.SuffixDn      = new Dn(ServerDNConstants.SYSTEM_DN);
            systemPartition.SchemaManager = service.SchemaManager;

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

            // Disable the ChangeLog system
            service.ChangeLog.Enabled         = false;
            service.DenormalizeOpAttrsEnabled = true;

            Partition camundaPartition = addPartition("camunda", BASE_DN, service.DnFactory);

            addIndex(camundaPartition, "objectClass", "ou", "uid");

            service.startup();

            // Create the root entry
            if (!service.AdminSession.exists(camundaPartition.SuffixDn))
            {
                Dn    dn    = new Dn(BASE_DN);
                Entry entry = service.newEntry(dn);
                entry.add("objectClass", "top", "domain", "extensibleObject");
                entry.add("dc", "camunda");
                service.AdminSession.add(entry);
            }
        }
コード例 #3
0
ファイル: MiniKdc.cs プロジェクト: orf53975/hadoop.net
        /// <exception cref="System.Exception"/>
        private void InitDirectoryService()
        {
            ds = new DefaultDirectoryService();
            ds.SetInstanceLayout(new InstanceLayout(workDir));
            CacheService cacheService = new CacheService();

            ds.SetCacheService(cacheService);
            // first load the schema
            InstanceLayout instanceLayout           = ds.GetInstanceLayout();
            FilePath       schemaPartitionDirectory = new FilePath(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 FilePath(ds.GetInstanceLayout().GetPartitionsDirectory
                                                              (), systemPartition.GetId()).ToURI());
            systemPartition.SetSuffixDn(new DN(ServerDNConstants.SystemDn));
            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(OrgName).ToLower(Extensions.GetEnglishCulture()
                                                               );
            string orgDomain = conf.GetProperty(OrgDomain).ToLower(Extensions.GetEnglishCulture()
                                                                   );
            JdbmPartition partition = new JdbmPartition(ds.GetSchemaManager());

            partition.SetId(orgName);
            partition.SetPartitionPath(new FilePath(ds.GetInstanceLayout().GetPartitionsDirectory
                                                        (), orgName).ToURI());
            partition.SetSuffixDn(new DN("dc=" + orgName + ",dc=" + orgDomain));
            ds.AddPartition(partition);
            // indexes
            ICollection <Index <object, object, string> > indexedAttributes = new HashSet <Index <
                                                                                               object, object, string> >();

            indexedAttributes.AddItem(new JdbmIndex <string, Org.Apache.Directory.Api.Ldap.Model.Entry.Entry
                                                     >("objectClass", false));
            indexedAttributes.AddItem(new JdbmIndex <string, Org.Apache.Directory.Api.Ldap.Model.Entry.Entry
                                                     >("dc", false));
            indexedAttributes.AddItem(new JdbmIndex <string, Org.Apache.Directory.Api.Ldap.Model.Entry.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);

            Org.Apache.Directory.Api.Ldap.Model.Entry.Entry entry = ds.NewEntry(dn);
            entry.Add("objectClass", "top", "domain");
            entry.Add("dc", orgName);
            ds.GetAdminSession().Add(entry);
        }