You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@directory.apache.org by "Louie, Kenneth W" <ke...@lmco.com> on 2014/02/11 19:53:29 UTC
Trying to create a partition programmatically - need help
I'm trying to create a partition programatically. I've tried following the example on the ApacheDS website (https://directory.apache.org/apacheds/basic-ug/1.4.3-adding-partition.html#adding-a-partition-programmatically) , but this example is definitely not correct.
Here is my code:
try {
LdapConnection connection = new LdapNetworkConnection(host, port);
connection.bind(admin, password);
log.info("Loading Schema...");
connection.loadSchema();
SchemaManager schemaManager = connection.getSchemaManager();
Dn suffixDn = new Dn(schemaManager, "dc=newParition,dc=com");
log.info("Start to create partition...");
JdbmPartition newPartition = new JdbmPartition(schemaManager);
newPartition.setId("newParition");
newPartition.setSuffixDn(suffixDn);
newPartition.setCacheSize(1000);
newPartition.setPartitionPath(new URI("file:///var/lib/apacheds-2.0.0-M15/default/partitions/newParition"));
newPartition.addIndex(new JdbmIndex("objectClass", false));
newPartition.addIndex(new JdbmIndex("dc", false));
Entry contextEntry = new DefaultEntry(schemaManager, suffixDn);
contextEntry.put("objectClass", "domain", "top");
contextEntry.put("dc", "newParition");
log.info("Initializing Parition");
newPartition.initialize();
log.info("Adding Entry to Partition");
newPartition.add(new AddOperationContext(null, contextEntry));
} catch (URISyntaxException ex) {
log.error("Error with partition location: " + ex);
} catch (Exception ex) {
log.error("Error creating partition: " + ex);
}
When I run this, I'm seeing:
Error creating partition: org.apache.directory.api.ldap.model.exception.LdapSchemaViolationException: ERR_219 Entry dc=newParition,dc=com contains no entryCsn attribute: Entry …
It doesn't even look like the partition is being added to my server (when I restart my apacheds server, I don't see any new namingContexts under the Root DSE). I think I'm missing some steps here, but not sure what they are. Can anyone help me? I'd greatly appreciate it.
Thanks
Re: Trying to create a partition programmatically - need help
Posted by NoSpam DeBusschere <te...@debusschere.com>.
I was able to create a solution that creates a partition and is active at runtime.
I just followed the basic initialization AD uses to create system partition on first start as basis.
I dynamically create an LDIF string with partition definitions which are added to config ldif.
Note, I got bit bad by some typos and CASE sensitivity issues on things like true/false from
what I remember. I used working definitions in config.ldif as template for what needed to be added.
----- Original Message -----
From: "Rishi" <ri...@zemosolabs.com>
To: "users" <us...@directory.apache.org>
Sent: Monday, January 19, 2015 7:56:12 AM
Subject: Re: Trying to create a partition programmatically - need help
Hi, I am trying the same thing and also facing same problem, did you found
any solution? Its really important
Thanks,
Re: Trying to create a partition programmatically - need help
Posted by Rishi <ri...@zemosolabs.com>.
Hi, I am trying the same thing and also facing same problem, did you found
any solution? Its really important
Thanks,
Re: Trying to create a partition programmatically - need help
Posted by Kiran Ayyagari <ka...@apache.org>.
checkout this example[1] use the revision 1563612 if you want to test
against M15
[1]
http://svn.apache.org/repos/asf/directory/sandbox/kayyagari/embedded-sample-trunk/
On Wed, Feb 12, 2014 at 12:23 AM, Louie, Kenneth W <kenneth.w.louie@lmco.com
> wrote:
> I'm trying to create a partition programatically. I've tried following the
> example on the ApacheDS website (
> https://directory.apache.org/apacheds/basic-ug/1.4.3-adding-partition.html#adding-a-partition-programmatically)
> , but this example is definitely not correct.
>
> Here is my code:
>
> try {
> LdapConnection connection = new LdapNetworkConnection(host, port);
> connection.bind(admin, password);
>
> log.info("Loading Schema...");
> connection.loadSchema();
> SchemaManager schemaManager = connection.getSchemaManager();
> Dn suffixDn = new Dn(schemaManager, "dc=newParition,dc=com");
>
> log.info("Start to create partition...");
> JdbmPartition newPartition = new JdbmPartition(schemaManager);
> newPartition.setId("newParition");
> newPartition.setSuffixDn(suffixDn);
> newPartition.setCacheSize(1000);
> newPartition.setPartitionPath(new
> URI("file:///var/lib/apacheds-2.0.0-M15/default/partitions/newParition"));
>
> newPartition.addIndex(new JdbmIndex("objectClass", false));
> newPartition.addIndex(new JdbmIndex("dc", false));
>
> Entry contextEntry = new DefaultEntry(schemaManager, suffixDn);
> contextEntry.put("objectClass", "domain", "top");
> contextEntry.put("dc", "newParition");
>
> log.info("Initializing Parition");
> newPartition.initialize();
> log.info("Adding Entry to Partition");
> newPartition.add(new AddOperationContext(null, contextEntry));
> } catch (URISyntaxException ex) {
> log.error("Error with partition location: " + ex);
> } catch (Exception ex) {
> log.error("Error creating partition: " + ex);
> }
>
> When I run this, I'm seeing:
>
> Error creating partition:
> org.apache.directory.api.ldap.model.exception.LdapSchemaViolationException:
> ERR_219 Entry dc=newParition,dc=com contains no entryCsn attribute: Entry ...
>
> It doesn't even look like the partition is being added to my server (when
> I restart my apacheds server, I don't see any new namingContexts under the
> Root DSE). I think I'm missing some steps here, but not sure what they are.
> Can anyone help me? I'd greatly appreciate it.
>
> Thanks
>
>
--
Kiran Ayyagari
http://keydap.com
Re: Trying to create a partition programmatically - need help
Posted by Emmanuel Lécharny <el...@gmail.com>.
Please, don't cross post. Select one single mailing list, the one that
fits : here, it's users.
Le 2/11/14 7:53 PM, Louie, Kenneth W a écrit :
> I'm trying to create a partition programatically. I've tried following the example on the ApacheDS website (https://directory.apache.org/apacheds/basic-ug/1.4.3-adding-partition.html#adding-a-partition-programmatically) , but this example is definitely not correct.
>
> Here is my code:
>
> try {
> LdapConnection connection = new LdapNetworkConnection(host, port);
> connection.bind(admin, password);
>
> log.info("Loading Schema...");
> connection.loadSchema();
> SchemaManager schemaManager = connection.getSchemaManager();
> Dn suffixDn = new Dn(schemaManager, "dc=newParition,dc=com");
>
> log.info("Start to create partition...");
> JdbmPartition newPartition = new JdbmPartition(schemaManager);
> newPartition.setId("newParition");
> newPartition.setSuffixDn(suffixDn);
> newPartition.setCacheSize(1000);
> newPartition.setPartitionPath(new URI("file:///var/lib/apacheds-2.0.0-M15/default/partitions/newParition"));
>
> newPartition.addIndex(new JdbmIndex("objectClass", false));
> newPartition.addIndex(new JdbmIndex("dc", false));
>
> Entry contextEntry = new DefaultEntry(schemaManager, suffixDn);
> contextEntry.put("objectClass", "domain", "top");
> contextEntry.put("dc", "newParition");
>
> log.info("Initializing Parition");
> newPartition.initialize();
> log.info("Adding Entry to Partition");
> newPartition.add(new AddOperationContext(null, contextEntry));
> } catch (URISyntaxException ex) {
> log.error("Error with partition location: " + ex);
> } catch (Exception ex) {
> log.error("Error creating partition: " + ex);
> }
>
> When I run this, I'm seeing:
>
> Error creating partition: org.apache.directory.api.ldap.model.exception.LdapSchemaViolationException: ERR_219 Entry dc=newParition,dc=com contains no entryCsn attribute: Entry …
>
> It doesn't even look like the partition is being added to my server (when I restart my apacheds server, I don't see any new namingContexts under the Root DSE). I think I'm missing some steps here, but not sure what they are. Can anyone help me? I'd greatly appreciate it.
>
> Thanks
>
--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com
Re: Trying to create a partition programmatically - need help
Posted by Kiran Ayyagari <ka...@apache.org>.
On Wed, Feb 12, 2014 at 11:42 PM, Louie, Kenneth W <kenneth.w.louie@lmco.com
> wrote:
> How do I add/configure a partition over the network? Is there an example I
> can go off?
>
> you need to add all the entries that are shown in this example
http://d.pr/n/2B0q
You need to replace the value of ads-partitionSuffix with dc=
newParition,dc=com
and ads-partitionId with some unique value like 'newPartition' (can be
anything)
then restart the server and finally add the below shown context entry.
> When I initialize the partition in the code below, I see the files being
> created. However, when I restart my ApacheDS server, and try to add the
> context entry, I'm this error seeing:
>
> looks like the partition wasn't created
> 2014-02-12 13:06:57,741 PartitionCommand [ERROR] Error creating partition:
> org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException:
> NO_SUCH_OBJECT: failed for MessageType : ADD_REQUEST
> Message ID : 4
> Add Request :
> Entry
> dn[n]: dc= newParition,dc=com
> objectClass: top
> objectClass: domain
> dc: newParition
> : ERR_268 Cannot find a partition for dc= newParition,dc=com
>
> When I create a partition through Studio, and restart the server, I see a
> partition entry in the config.ldif. I assume I need to create that entry
> using the java api? Is there an example on how to do this?
>
> the same as mentioned above, just add all those config entries first using
API, then restart before adding
the context entry
> Appreciate the help. Thanks.
>
> From: <Louie>, "Louie, Kenneth W" <kenneth.w.louie@lmco.com<mailto:
> kenneth.w.louie@lmco.com>>
> Date: Wednesday, February 12, 2014 10:50 AM
> To: "users@directory.apache.org<ma...@directory.apache.org>" <
> users@directory.apache.org<ma...@directory.apache.org>>
> Subject: Re: Trying to create a partition programmatically - need help
>
> I'm trying to create a new partition on a remote ApacheDS server. I can do
> it through the Studio, but I would like to automate this process. Is it
> possible to do this programmatically? The examples I see are for an
> embedded server.
>
> Thanks
>
> From: <Louie>, "Louie, Kenneth W" <kenneth.w.louie@lmco.com<mailto:
> kenneth.w.louie@lmco.com>>
> Date: Tuesday, February 11, 2014 1:53 PM
> To: "api@directory.apache.org<ma...@directory.apache.org>" <
> api@directory.apache.org<ma...@directory.apache.org>>, "
> users@directory.apache.org<ma...@directory.apache.org>" <
> users@directory.apache.org<ma...@directory.apache.org>>
> Subject: Trying to create a partition programmatically - need help
>
> I'm trying to create a partition programatically. I've tried following the
> example on the ApacheDS website (
> https://directory.apache.org/apacheds/basic-ug/1.4.3-adding-partition.html#adding-a-partition-programmatically)
> , but this example is definitely not correct.
>
> Here is my code:
>
> try {
> LdapConnection connection = new LdapNetworkConnection(host, port);
> connection.bind(admin, password);
>
> log.info("Loading Schema...");
> connection.loadSchema();
> SchemaManager schemaManager = connection.getSchemaManager();
> Dn suffixDn = new Dn(schemaManager, "dc=newParition,dc=com");
>
> log.info("Start to create partition...");
> JdbmPartition newPartition = new JdbmPartition(schemaManager);
> newPartition.setId("newParition");
> newPartition.setSuffixDn(suffixDn);
> newPartition.setCacheSize(1000);
> newPartition.setPartitionPath(new
> URI("file:///var/lib/apacheds-2.0.0-M15/default/partitions/newParition"));
>
> newPartition.addIndex(new JdbmIndex("objectClass", false));
> newPartition.addIndex(new JdbmIndex("dc", false));
>
> Entry contextEntry = new DefaultEntry(schemaManager, suffixDn);
> contextEntry.put("objectClass", "domain", "top");
> contextEntry.put("dc", "newParition");
>
> log.info("Initializing Parition");
> newPartition.initialize();
> log.info("Adding Entry to Partition");
> newPartition.add(new AddOperationContext(null, contextEntry));
> } catch (URISyntaxException ex) {
> log.error("Error with partition location: " + ex);
> } catch (Exception ex) {
> log.error("Error creating partition: " + ex);
> }
>
> When I run this, I'm seeing:
>
> Error creating partition:
> org.apache.directory.api.ldap.model.exception.LdapSchemaViolationException:
> ERR_219 Entry dc=newParition,dc=com contains no entryCsn attribute: Entry ...
>
> It doesn't even look like the partition is being added to my server (when
> I restart my apacheds server, I don't see any new namingContexts under the
> Root DSE). I think I'm missing some steps here, but not sure what they are.
> Can anyone help me? I'd greatly appreciate it.
>
> Thanks
>
>
--
Kiran Ayyagari
http://keydap.com
Re: Trying to create a partition programmatically - need help
Posted by "Louie, Kenneth W" <ke...@lmco.com>.
How do I add/configure a partition over the network? Is there an example I can go off?
When I initialize the partition in the code below, I see the files being created. However, when I restart my ApacheDS server, and try to add the context entry, I'm this error seeing:
2014-02-12 13:06:57,741 PartitionCommand [ERROR] Error creating partition: org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException: NO_SUCH_OBJECT: failed for MessageType : ADD_REQUEST
Message ID : 4
Add Request :
Entry
dn[n]: dc= newParition,dc=com
objectClass: top
objectClass: domain
dc: newParition
: ERR_268 Cannot find a partition for dc= newParition,dc=com
When I create a partition through Studio, and restart the server, I see a partition entry in the config.ldif. I assume I need to create that entry using the java api? Is there an example on how to do this?
Appreciate the help. Thanks.
From: <Louie>, "Louie, Kenneth W" <ke...@lmco.com>>
Date: Wednesday, February 12, 2014 10:50 AM
To: "users@directory.apache.org<ma...@directory.apache.org>" <us...@directory.apache.org>>
Subject: Re: Trying to create a partition programmatically - need help
I'm trying to create a new partition on a remote ApacheDS server. I can do it through the Studio, but I would like to automate this process. Is it possible to do this programmatically? The examples I see are for an embedded server.
Thanks
From: <Louie>, "Louie, Kenneth W" <ke...@lmco.com>>
Date: Tuesday, February 11, 2014 1:53 PM
To: "api@directory.apache.org<ma...@directory.apache.org>" <ap...@directory.apache.org>>, "users@directory.apache.org<ma...@directory.apache.org>" <us...@directory.apache.org>>
Subject: Trying to create a partition programmatically - need help
I'm trying to create a partition programatically. I've tried following the example on the ApacheDS website (https://directory.apache.org/apacheds/basic-ug/1.4.3-adding-partition.html#adding-a-partition-programmatically) , but this example is definitely not correct.
Here is my code:
try {
LdapConnection connection = new LdapNetworkConnection(host, port);
connection.bind(admin, password);
log.info("Loading Schema...");
connection.loadSchema();
SchemaManager schemaManager = connection.getSchemaManager();
Dn suffixDn = new Dn(schemaManager, "dc=newParition,dc=com");
log.info("Start to create partition...");
JdbmPartition newPartition = new JdbmPartition(schemaManager);
newPartition.setId("newParition");
newPartition.setSuffixDn(suffixDn);
newPartition.setCacheSize(1000);
newPartition.setPartitionPath(new URI("file:///var/lib/apacheds-2.0.0-M15/default/partitions/newParition"));
newPartition.addIndex(new JdbmIndex("objectClass", false));
newPartition.addIndex(new JdbmIndex("dc", false));
Entry contextEntry = new DefaultEntry(schemaManager, suffixDn);
contextEntry.put("objectClass", "domain", "top");
contextEntry.put("dc", "newParition");
log.info("Initializing Parition");
newPartition.initialize();
log.info("Adding Entry to Partition");
newPartition.add(new AddOperationContext(null, contextEntry));
} catch (URISyntaxException ex) {
log.error("Error with partition location: " + ex);
} catch (Exception ex) {
log.error("Error creating partition: " + ex);
}
When I run this, I'm seeing:
Error creating partition: org.apache.directory.api.ldap.model.exception.LdapSchemaViolationException: ERR_219 Entry dc=newParition,dc=com contains no entryCsn attribute: Entry …
It doesn't even look like the partition is being added to my server (when I restart my apacheds server, I don't see any new namingContexts under the Root DSE). I think I'm missing some steps here, but not sure what they are. Can anyone help me? I'd greatly appreciate it.
Thanks
Re: Trying to create a partition programmatically - need help
Posted by Kiran Ayyagari <ka...@apache.org>.
On Wed, Feb 12, 2014 at 9:21 PM, Louie, Kenneth W
<ke...@lmco.com>wrote:
> I'm trying to create a new partition on a remote ApacheDS server. I can do
> it through the Studio, but I would
what you are adding through studio is a context(a.k.a root) entry of the
partition (like dc=example,dc=com)
> like to automate this process. Is it possible to do this programmatically?
> The examples I see are for an embedded server.
>
> you can add('configure', strictly speaking) a partition over network but
the server must be restarted
to make it usable.
Thanks
>
> From: <Louie>, "Louie, Kenneth W" <kenneth.w.louie@lmco.com<mailto:
> kenneth.w.louie@lmco.com>>
> Date: Tuesday, February 11, 2014 1:53 PM
> To: "api@directory.apache.org<ma...@directory.apache.org>" <
> api@directory.apache.org<ma...@directory.apache.org>>, "
> users@directory.apache.org<ma...@directory.apache.org>" <
> users@directory.apache.org<ma...@directory.apache.org>>
> Subject: Trying to create a partition programmatically - need help
>
> I'm trying to create a partition programatically. I've tried following the
> example on the ApacheDS website (
> https://directory.apache.org/apacheds/basic-ug/1.4.3-adding-partition.html#adding-a-partition-programmatically)
> , but this example is definitely not correct.
>
> Here is my code:
>
> try {
> LdapConnection connection = new LdapNetworkConnection(host, port);
> connection.bind(admin, password);
>
> log.info("Loading Schema...");
> connection.loadSchema();
> SchemaManager schemaManager = connection.getSchemaManager();
> Dn suffixDn = new Dn(schemaManager, "dc=newParition,dc=com");
>
> log.info("Start to create partition...");
> JdbmPartition newPartition = new JdbmPartition(schemaManager);
> newPartition.setId("newParition");
> newPartition.setSuffixDn(suffixDn);
> newPartition.setCacheSize(1000);
> newPartition.setPartitionPath(new
> URI("file:///var/lib/apacheds-2.0.0-M15/default/partitions/newParition"));
>
> newPartition.addIndex(new JdbmIndex("objectClass", false));
> newPartition.addIndex(new JdbmIndex("dc", false));
>
> Entry contextEntry = new DefaultEntry(schemaManager, suffixDn);
> contextEntry.put("objectClass", "domain", "top");
> contextEntry.put("dc", "newParition");
>
> log.info("Initializing Parition");
> newPartition.initialize();
> log.info("Adding Entry to Partition");
> newPartition.add(new AddOperationContext(null, contextEntry));
> } catch (URISyntaxException ex) {
> log.error("Error with partition location: " + ex);
> } catch (Exception ex) {
> log.error("Error creating partition: " + ex);
> }
>
> When I run this, I'm seeing:
>
> Error creating partition:
> org.apache.directory.api.ldap.model.exception.LdapSchemaViolationException:
> ERR_219 Entry dc=newParition,dc=com contains no entryCsn attribute: Entry ...
>
> It doesn't even look like the partition is being added to my server (when
> I restart my apacheds server, I don't see any new namingContexts under the
> Root DSE). I think I'm missing some steps here, but not sure what they are.
> Can anyone help me? I'd greatly appreciate it.
>
> Thanks
>
>
--
Kiran Ayyagari
http://keydap.com
Re: Trying to create a partition programmatically - need help
Posted by "Louie, Kenneth W" <ke...@lmco.com>.
I'm trying to create a new partition on a remote ApacheDS server. I can do it through the Studio, but I would like to automate this process. Is it possible to do this programmatically? The examples I see are for an embedded server.
Thanks
From: <Louie>, "Louie, Kenneth W" <ke...@lmco.com>>
Date: Tuesday, February 11, 2014 1:53 PM
To: "api@directory.apache.org<ma...@directory.apache.org>" <ap...@directory.apache.org>>, "users@directory.apache.org<ma...@directory.apache.org>" <us...@directory.apache.org>>
Subject: Trying to create a partition programmatically - need help
I'm trying to create a partition programatically. I've tried following the example on the ApacheDS website (https://directory.apache.org/apacheds/basic-ug/1.4.3-adding-partition.html#adding-a-partition-programmatically) , but this example is definitely not correct.
Here is my code:
try {
LdapConnection connection = new LdapNetworkConnection(host, port);
connection.bind(admin, password);
log.info("Loading Schema...");
connection.loadSchema();
SchemaManager schemaManager = connection.getSchemaManager();
Dn suffixDn = new Dn(schemaManager, "dc=newParition,dc=com");
log.info("Start to create partition...");
JdbmPartition newPartition = new JdbmPartition(schemaManager);
newPartition.setId("newParition");
newPartition.setSuffixDn(suffixDn);
newPartition.setCacheSize(1000);
newPartition.setPartitionPath(new URI("file:///var/lib/apacheds-2.0.0-M15/default/partitions/newParition"));
newPartition.addIndex(new JdbmIndex("objectClass", false));
newPartition.addIndex(new JdbmIndex("dc", false));
Entry contextEntry = new DefaultEntry(schemaManager, suffixDn);
contextEntry.put("objectClass", "domain", "top");
contextEntry.put("dc", "newParition");
log.info("Initializing Parition");
newPartition.initialize();
log.info("Adding Entry to Partition");
newPartition.add(new AddOperationContext(null, contextEntry));
} catch (URISyntaxException ex) {
log.error("Error with partition location: " + ex);
} catch (Exception ex) {
log.error("Error creating partition: " + ex);
}
When I run this, I'm seeing:
Error creating partition: org.apache.directory.api.ldap.model.exception.LdapSchemaViolationException: ERR_219 Entry dc=newParition,dc=com contains no entryCsn attribute: Entry …
It doesn't even look like the partition is being added to my server (when I restart my apacheds server, I don't see any new namingContexts under the Root DSE). I think I'm missing some steps here, but not sure what they are. Can anyone help me? I'd greatly appreciate it.
Thanks