...
Code Block | ||||
---|---|---|---|---|
| ||||
...
public void init(DirectoryService core) throws Exception {
// Create LDAP DN
suffixDn = new LdapDN(suffix);
suffixDn.normalize(core.getRegistries().getAttributeTypeRegistry().getNormalizerMapping());
Rdn rdn = suffixDn.getRdn();
// Create the only entry in this partition
ServerEntry entry = new DefaultServerEntry(core
.getRegistries(), this.suffixDn);
entry.put(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC,
SchemaConstants.ORGANIZATIONAL_UNIT_OC);
entry.put(SchemaConstants.OU_AT, rdn.getUpValue().toString());
entry.put("description", "hello, world", "a minimal partition");
this.helloEntry = entry;
}
...
{code:java}
The _ |
The Partition_interface
...
requires
...
to
...
implement
...
many
...
methods
...
for
...
all
...
the
...
operations
...
a
...
partition
...
should
...
support
...
(adding,
...
deleting,
...
modifying
...
entries
...
...).
...
Due
...
to
...
the
...
fact,
...
that
...
this
...
is
...
a
...
readonly
...
partition,
...
the
...
implementation
...
in
...
our
...
case
...
is
...
minimalistic.
...
Here
...
is
...
the
...
_
...
delete method
...
as
...
an
...
example.
Code Block | ||||
---|---|---|---|---|
| ||||
{code:java} ... public void delete(DeleteOperationContext opContext) throws LdapOperationNotSupportedException { throw new LdapOperationNotSupportedException( MODIFICATION_NOT_ALLOWED_MSG, ResultCodeEnum.UNWILLING_TO_PERFORM); } ... {code:java} |
TBD:
...
search
...
Using
...
the
...
partition
...
Embedded
...
mode
Code Block | ||||
---|---|---|---|---|
| ||||
{code:java} package org.apache.directory.samples.partition.hello; import org.apache.directory.server.core.DefaultDirectoryService; import org.apache.directory.server.core.DirectoryService; import org.apache.directory.server.ldap.LdapService; import org.apache.directory.server.protocol.shared.SocketAcceptor; public class Main { public static void main(String[] args) throws Exception { DirectoryService directoryService; SocketAcceptor socketAcceptor; LdapService ldapService; directoryService = new DefaultDirectoryService(); directoryService.setShutdownHookEnabled(true); socketAcceptor = new SocketAcceptor(null); ldapService = new LdapService(); ldapService.setSocketAcceptor(socketAcceptor); ldapService.setDirectoryService(directoryService); ldapService.setIpPort(10389); HelloWorldPartition helloPartition = new HelloWorldPartition(); helloPartition.setSuffix("ou=helloWorld"); helloPartition.init(directoryService); directoryService.addPartition(helloPartition); directoryService.startup(); ldapService.start(); } } |
...