You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Spark Shen <sm...@gmail.com> on 2007/11/01 07:44:09 UTC

[ldapserver][schema] How to programmatically extract schema information from a server context

Hi

I am now using DS server (apacheds-main-0.9.3.jar) for writing test cases.
But I encounter problems when listing schema.
Problem Description:
1. Construct server context
configuration = new MutableServerStartupConfiguration();
configuration.setWorkingDirectory(new File(workingDir));
cleanWorkingDir(configuration.getWorkingDirectory());
port = AvailablePortFinder.getNextAvailable(1024);
configuration.setLdapPort(port);
        // configuration.setShutdownHookEnabled(false);
serverEnv = new Hashtable<String, Object>(configuration
                .toJndiEnvironment());

serverEnv.put(Context.INITIAL_CONTEXT_FACTORY,
                ServerContextFactory.class.getName());

serverEnv.put(Context.PROVIDER_URL, "");

serverEnv.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
serverEnv.put(Context.SECURITY_CREDENTIALS, "secret");
serverEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
rootDSE = new InitialLdapContext(serverEnv, null);

2. List schema for this context

            DirContext pairs = super.rootDSE.getSchema("");
            NamingEnumeration<NameClassPair> ps = pairs.list
("objectClasses");
            while(ps.hasMore()) {
                System.out.println(ps.next());
            }

And 'java.lang.UnsupportedOperationException' was thrown. I did not find a
quick instruction
on how to list schemas, would anyone give a hand?

-- 
Spark Shen
China Software Development Lab, IBM

Re: [ldapserver][schema] How to programmatically extract schema information from a server context

Posted by Spark Shen <sm...@gmail.com>.
Hi Ole,

Thanks very much for your information. Would you give the detailed link?
I will try to find the link, but seems the code base is huge.

Regards

2007/11/5, Ole Ersoy <ol...@gmail.com>:
>
> Hi Spark,
>
> There are a lot of of Schema Unit tests for the LDAP DAS in Apache
> Tuscany. They all pass on ADS 1.51, run the server embedded, and seem to
> fit with what you have listed below.
>
> Cheers,
> - Ole
>
> Emmanuel Lecharny wrote:
> > Spark Shen wrote:
> >> I noticed 1.5 and 1.0 are two separate product version. I'd like to
> >> have a try on 1.5. What is the counter-part jar on 1.5?
> > 1.5 includes may improvements (performances, stability) and regarding
> > schema, they are now self contained (each objectclass and attribute is
> > an entry in the cn=schema,ou=system partition)
> >
> > Be aware that we currently don't have described yet how to design unit
> > tests for 1.5, due to lack of time ... (even if the site claims so ;)
> >> BTW, is my code correct to extract schema info?
> > I have no idea, I haven't looked at it yet :)
> >
> > If you are following the JNDI tutorial
> > (http://java.sun.com/products/jndi/tutorial/ldap/schema/index.html), it
> > should be OK. Otherwise, if you have a problem, then it may be a bug,
> > and it will deserve a JIRA.
> >
> > I must also admit I don't have time to copy/paste the code into my dev
> > env to check the code.
> >>
> >> 2007/11/1, Emmanuel Lecharny < elecharny@gmail.com
> >> <ma...@gmail.com>>:
> >>
> >>     Spark Shen wrote:
> >>     > Hi
> >>     >
> >>     > I am now using DS server (apacheds-main-0.9.3.jar) for writing
> test
> >>     > cases. But I encounter problems when listing schema.
> >>     > Problem Description:
> >>     > 1. Construct server context
> >>     > configuration = new MutableServerStartupConfiguration();
> >>     > configuration.setWorkingDirectory(new File(workingDir));
> >>     > cleanWorkingDir(configuration.getWorkingDirectory());
> >>     > port = AvailablePortFinder.getNextAvailable (1024);
> >>     > configuration.setLdapPort(port);
> >>     >         // configuration.setShutdownHookEnabled(false);
> >>     > serverEnv = new Hashtable<String, Object>(configuration
> >>     >                 .toJndiEnvironment());
> >>     >
> >>     > serverEnv.put(Context.INITIAL_CONTEXT_FACTORY,
> >>     >                 ServerContextFactory.class.getName());
> >>     >
> >>     > serverEnv.put(Context.PROVIDER_URL, "");
> >>     >
> >>     > serverEnv.put (Context.SECURITY_PRINCIPAL,
> "uid=admin,ou=system");
> >>     > serverEnv.put(Context.SECURITY_CREDENTIALS , "secret");
> >>     > serverEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
> >>     > rootDSE = new InitialLdapContext(serverEnv, null);
> >>     >
> >>     > 2. List schema for this context
> >>     >
> >>     >             DirContext pairs = super.rootDSE.getSchema("");
> >>     >             NamingEnumeration<NameClassPair> ps =
> >>     > pairs.list("objectClasses");
> >>     >             while(ps.hasMore()) {
> >>     >                 System.out.println(ps.next());
> >>     >             }
> >>     >
> >>     > And 'java.lang.UnsupportedOperationException' was thrown. I did
> not
> >>     > find a quick instruction
> >>     > on how to list schemas, would anyone give a hand?
> >>     What about switching to ADS 1.0.2 instead of a badly outdated 0.9.3
> >>     version ?
> >>
> >>     >
> >>     > --
> >>     > Spark Shen
> >>     > China Software Development Lab, IBM
> >>
> >>
> >>     --
> >>     --
> >>     cordialement, regards,
> >>     Emmanuel Lécharny
> >>     www.iktek.com <http://www.iktek.com>
> >>     directory.apache.org <http://directory.apache.org>
> >>
> >>
> >>
> >>
> >>
> >> --
> >> Spark Shen
> >> China Software Development Lab, IBM
> >
> >
>



-- 
Spark Shen
China Software Development Lab, IBM

Re: [ldapserver][schema] How to programmatically extract schema information from a server context

Posted by Ole Ersoy <ol...@gmail.com>.
This is a Tuscany repackaging of the original contribution, so it's possible that it introduced a few hairballs.  I'll email you the original contribution that builds correctly.  It looks as if the dependencies are specific to Tuscany, and it's possible that Tuscany put them in a local maven repository.  If they did, it has to be added your repository list in maven's settings.xml.  This enables maven to look for missing dependencies.

I'll put the original contribution contribution in a separate mail.



Spark Shen wrote:
> Two jar files are missing,
> 1. das.ldap.configuration.model.v100-1.0-incubating-SNAPSHOT.jar
> 2.das.ldap.constants-1.0-incubating-SNAPSHOT.jar
> they can not be found here:
> http://people.apache.org/repo/m2-snapshot-repository/org/apache/tuscany/das/tuscany-das/1.0-incubating-SNAPSHOT/
> 
> 2007/11/14, Ole Ersoy <ole.ersoy@gmail.com <ma...@gmail.com>>:
> 
> 
> 
>     Spark Shen wrote:
>      > And I got the java.lang.UnsupportedOperationException .
>      > I am not quite sure whether its my program is wrong or the retrieving
>      > schema
>      > operation is not supported.
> 
>     I'm guessing you tried it on some version prior to 1.50 or 1.51?
> 
>      >
>      > Besides the file you mentioned, I looked into another file:
>      >
>     http://svn.apache.org/repos/asf/incubator/tuscany/java/das/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/connect/test/ADSEmbeddedConnectionTest.java
>      >
>      > and find a code snippet:
>      >
>      > LdapContext schemaContext = adsEmbeddedConnection.
>      >
>      >                       connect(configuration.
>      >                                       getSchemaPartitionName());
>      >
>      > then what I want to do is:
>      > schemaContext.list("")
> 
>      >
>      > The test case itself relies on many third party jars.
>      > I did not have a maven env, and am trying to configure one.
>      >
>      > Seems it will take me some efforts to find all the dependent
>     jars, and then play with it.
> 
>     Maven should pull them all down for you and install them in your local
>     repository, once you have maven installed.
> 
>     So once you have the mvn command working, you simply cd into the
>     ldap das
>     project root and run
> 
>     "mvn clean install"
> 
>     Maven will download all the dependencies for you.
> 
>     Then run
>     "mvn eclipse:eclipse"
> 
>     at the project root and maven will turn the projects into eclipse
>     projects
>     that you can import and play with.
> 
> 
>      > Where can I find the developer guide?
>      > http://incubator.apache.org/tuscany/starting-with-das.htmll
>     <http://incubator.apache.org/tuscany/starting-with-das.htmll>
>      >  <http://incubator.apache.org/tuscany/starting-with-das.htmll> ?
>      >
>     I wrote some documentation here:
>     https://svn.apache.org/repos/asf/directory/sandbox/oersoy/guides/das.ldap.design.documentation/
> 
>     Still need to finish this up.  I used it to get moving on the DAS
>     and then once I had momentum, I just finished the initial
>     implementation.  It's an eclipse documentation plugin, so just
>     download and drop into your eclipse plugins folder.
> 
>      > If it will not cost you too much energy, would you give me a
>     standalone main file which can start an apacheds server,
>      > and then get the schemaContext, and at last list all the schema
>     entries?
>      >
> 
>     There's also a maven archetype that I have created specifically for
>     this purpose that is located in my Sandbox.
> 
>     http://svn.apache.org/repos/asf/directory/sandbox/oersoy/apacheds.testing.archetype
> 
>     This will enable you to create a project starting point for
>     experimentation.  It does require you to be familiar with maven and
>     maven archetypes.
> 
> 
> 
> 
> -- 
> Spark Shen
> China Software Development Lab, IBM

Re: [ldapserver][schema] How to programmatically extract schema information from a server context

Posted by Spark Shen <sm...@gmail.com>.
Two jar files are missing,
1. das.ldap.configuration.model.v100-1.0-incubating-SNAPSHOT.jar
2.das.ldap.constants-1.0-incubating-SNAPSHOT.jar
they can not be found here:
http://people.apache.org/repo/m2-snapshot-repository/org/apache/tuscany/das/tuscany-das/1.0-incubating-SNAPSHOT/

2007/11/14, Ole Ersoy <ol...@gmail.com>:
>
>
>
> Spark Shen wrote:
> > And I got the java.lang.UnsupportedOperationException .
> > I am not quite sure whether its my program is wrong or the retrieving
> > schema
> > operation is not supported.
>
> I'm guessing you tried it on some version prior to 1.50 or 1.51?
>
> >
> > Besides the file you mentioned, I looked into another file:
> >
> http://svn.apache.org/repos/asf/incubator/tuscany/java/das/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/connect/test/ADSEmbeddedConnectionTest.java
> >
> > and find a code snippet:
> >
> > LdapContext schemaContext = adsEmbeddedConnection.
> >
> >                       connect(configuration.
> >                                       getSchemaPartitionName());
> >
> > then what I want to do is:
> > schemaContext.list("")
>
> >
> > The test case itself relies on many third party jars.
> > I did not have a maven env, and am trying to configure one.
> >
> > Seems it will take me some efforts to find all the dependent jars, and
> then play with it.
>
> Maven should pull them all down for you and install them in your local
> repository, once you have maven installed.
>
> So once you have the mvn command working, you simply cd into the ldap das
> project root and run
>
> "mvn clean install"
>
> Maven will download all the dependencies for you.
>
> Then run
> "mvn eclipse:eclipse"
>
> at the project root and maven will turn the projects into eclipse projects
> that you can import and play with.
>
>
> > Where can I find the developer guide?
> > http://incubator.apache.org/tuscany/starting-with-das.htmll
> >  <http://incubator.apache.org/tuscany/starting-with-das.htmll> ?
> >
> I wrote some documentation here:
>
> https://svn.apache.org/repos/asf/directory/sandbox/oersoy/guides/das.ldap.design.documentation/
>
> Still need to finish this up.  I used it to get moving on the DAS and then
> once I had momentum, I just finished the initial implementation.  It's an
> eclipse documentation plugin, so just download and drop into your eclipse
> plugins folder.
>
> > If it will not cost you too much energy, would you give me a standalone
> main file which can start an apacheds server,
> > and then get the schemaContext, and at last list all the schema entries?
> >
>
> There's also a maven archetype that I have created specifically for this
> purpose that is located in my Sandbox.
>
>
> http://svn.apache.org/repos/asf/directory/sandbox/oersoy/apacheds.testing.archetype
>
> This will enable you to create a project starting point for
> experimentation.  It does require you to be familiar with maven and maven
> archetypes.
>



-- 
Spark Shen
China Software Development Lab, IBM

Re: [ldapserver][schema] How to programmatically extract schema information from a server context

Posted by Ole Ersoy <ol...@gmail.com>.
Great!  The test cases that create and read schema entries should help you figure out how to extract the entire schema.  Does that solve the ADSEmbeddedConnectionTest issue then?  All the DAS tests use a similar setup.

Spark Shen wrote:
> I finally built the project, thanks.
> 
> 2007/11/14, Ole Ersoy <ole.ersoy@gmail.com <ma...@gmail.com>>:
> 
> 
> 
>     Spark Shen wrote:
>      > And I got the java.lang.UnsupportedOperationException .
>      > I am not quite sure whether its my program is wrong or the retrieving
>      > schema
>      > operation is not supported.
> 
>     I'm guessing you tried it on some version prior to 1.50 or 1.51?
> 
>      >
>      > Besides the file you mentioned, I looked into another file:
>      >
>     http://svn.apache.org/repos/asf/incubator/tuscany/java/das/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/connect/test/ADSEmbeddedConnectionTest.java
>      >
>      > and find a code snippet:
>      >
>      > LdapContext schemaContext = adsEmbeddedConnection.
>      >
>      >                       connect(configuration.
>      >                                       getSchemaPartitionName());
>      >
>      > then what I want to do is:
>      > schemaContext.list("")
> 
>      >
>      > The test case itself relies on many third party jars.
>      > I did not have a maven env, and am trying to configure one.
>      >
>      > Seems it will take me some efforts to find all the dependent
>     jars, and then play with it.
> 
>     Maven should pull them all down for you and install them in your local
>     repository, once you have maven installed.
> 
>     So once you have the mvn command working, you simply cd into the
>     ldap das
>     project root and run
> 
>     "mvn clean install"
> 
>     Maven will download all the dependencies for you.
> 
>     Then run
>     "mvn eclipse:eclipse"
> 
>     at the project root and maven will turn the projects into eclipse
>     projects
>     that you can import and play with.
> 
> 
>      > Where can I find the developer guide?
>      > http://incubator.apache.org/tuscany/starting-with-das.htmll
>     <http://incubator.apache.org/tuscany/starting-with-das.htmll>
>      >  <http://incubator.apache.org/tuscany/starting-with-das.htmll> ?
>      >
>     I wrote some documentation here:
>     https://svn.apache.org/repos/asf/directory/sandbox/oersoy/guides/das.ldap.design.documentation/
> 
>     Still need to finish this up.  I used it to get moving on the DAS
>     and then once I had momentum, I just finished the initial
>     implementation.  It's an eclipse documentation plugin, so just
>     download and drop into your eclipse plugins folder.
> 
>      > If it will not cost you too much energy, would you give me a
>     standalone main file which can start an apacheds server,
>      > and then get the schemaContext, and at last list all the schema
>     entries?
>      >
> 
>     There's also a maven archetype that I have created specifically for
>     this purpose that is located in my Sandbox.
> 
>     http://svn.apache.org/repos/asf/directory/sandbox/oersoy/apacheds.testing.archetype
> 
>     This will enable you to create a project starting point for
>     experimentation.  It does require you to be familiar with maven and
>     maven archetypes.
> 
> 
> 
> 
> -- 
> Spark Shen
> China Software Development Lab, IBM

Re: [ldapserver][schema] How to programmatically extract schema information from a server context

Posted by Spark Shen <sm...@gmail.com>.
I finally built the project, thanks.

2007/11/14, Ole Ersoy <ol...@gmail.com>:
>
>
>
> Spark Shen wrote:
> > And I got the java.lang.UnsupportedOperationException .
> > I am not quite sure whether its my program is wrong or the retrieving
> > schema
> > operation is not supported.
>
> I'm guessing you tried it on some version prior to 1.50 or 1.51?
>
> >
> > Besides the file you mentioned, I looked into another file:
> >
> http://svn.apache.org/repos/asf/incubator/tuscany/java/das/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/connect/test/ADSEmbeddedConnectionTest.java
> >
> > and find a code snippet:
> >
> > LdapContext schemaContext = adsEmbeddedConnection.
> >
> >                       connect(configuration.
> >                                       getSchemaPartitionName());
> >
> > then what I want to do is:
> > schemaContext.list("")
>
> >
> > The test case itself relies on many third party jars.
> > I did not have a maven env, and am trying to configure one.
> >
> > Seems it will take me some efforts to find all the dependent jars, and
> then play with it.
>
> Maven should pull them all down for you and install them in your local
> repository, once you have maven installed.
>
> So once you have the mvn command working, you simply cd into the ldap das
> project root and run
>
> "mvn clean install"
>
> Maven will download all the dependencies for you.
>
> Then run
> "mvn eclipse:eclipse"
>
> at the project root and maven will turn the projects into eclipse projects
> that you can import and play with.
>
>
> > Where can I find the developer guide?
> > http://incubator.apache.org/tuscany/starting-with-das.htmll
> >  <http://incubator.apache.org/tuscany/starting-with-das.htmll> ?
> >
> I wrote some documentation here:
>
> https://svn.apache.org/repos/asf/directory/sandbox/oersoy/guides/das.ldap.design.documentation/
>
> Still need to finish this up.  I used it to get moving on the DAS and then
> once I had momentum, I just finished the initial implementation.  It's an
> eclipse documentation plugin, so just download and drop into your eclipse
> plugins folder.
>
> > If it will not cost you too much energy, would you give me a standalone
> main file which can start an apacheds server,
> > and then get the schemaContext, and at last list all the schema entries?
> >
>
> There's also a maven archetype that I have created specifically for this
> purpose that is located in my Sandbox.
>
>
> http://svn.apache.org/repos/asf/directory/sandbox/oersoy/apacheds.testing.archetype
>
> This will enable you to create a project starting point for
> experimentation.  It does require you to be familiar with maven and maven
> archetypes.
>



-- 
Spark Shen
China Software Development Lab, IBM

Re: [ldapserver][schema] How to programmatically extract schema information from a server context

Posted by Ole Ersoy <ol...@gmail.com>.
This is specific to ADS.  Something has been changed in the dependencies that the archetype runs with.  Lets see if we get the original DAS contribution that I just emailed you to compile correctly.  If that compiles then you have the same test case there.

Spark Shen wrote:
> One more question:
> When executing the test case 
> org.apache.tuscany.das.ldap.connect.test.ADSEmbeddedConnectionTest, I 
> got the following exception:
> org.apache.directory.server.schema.bootstrap.partition.UniqueResourceException 
> : Problem locating bootstrap partition database file list.  Be sure 
> there is exactly one bootstrap partition jar in your classpath.
> No resources named 
> 'org/apache/directory/server/schema/bootstrap/partition/DBFILES' located 
> on classpath
>     at 
> org.apache.directory.server.schema.bootstrap.partition.DbFileListing.getUniqueResource(DbFileListing.java:139)
>     at 
> org.apache.directory.server.schema.bootstrap.partition.DbFileListing.getUniqueResourceAsStream 
> (DbFileListing.java:129)
>     at 
> org.apache.directory.server.schema.bootstrap.partition.DbFileListing.init(DbFileListing.java:82)
>     at 
> org.apache.directory.server.schema.bootstrap.partition.DbFileListing.<init>( 
> DbFileListing.java:51)
>     at 
> org.apache.directory.server.schema.bootstrap.partition.SchemaPartitionExtractor.<init>(SchemaPartitionExtractor.java:43)
>     at 
> org.apache.directory.server.core.DefaultDirectoryService.initialize 
> (DefaultDirectoryService.java:833)
>     at 
> org.apache.directory.server.core.DefaultDirectoryService.startup(DefaultDirectoryService.java:254)
>     at 
> org.apache.directory.server.core.jndi.AbstractContextFactory.getInitialContext 
> (AbstractContextFactory.java:124)
>     at 
> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
>     at 
> javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
>     at javax.naming.InitialContext.init (InitialContext.java:223)
>     at 
> javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java:134)
>     at 
> org.apache.tuscany.das.ldap.connect.ADSEmbeddedConnection.startup(ADSEmbeddedConnection.java:159) 
> 
>     at 
> org.apache.tuscany.das.ldap.connect.ADSEmbeddedConnection.connect(ADSEmbeddedConnection.java:164)
>     at 
> org.apache.tuscany.das.ldap.connect.test.ADSEmbeddedConnectionTest.testConnect(ADSEmbeddedConnectionTest.java 
> :25)
> 
> 
> 
> 2007/11/14, Ole Ersoy <ole.ersoy@gmail.com <ma...@gmail.com>>:
> 
> 
> 
>     Spark Shen wrote:
>      > And I got the java.lang.UnsupportedOperationException .
>      > I am not quite sure whether its my program is wrong or the retrieving
>      > schema
>      > operation is not supported.
> 
>     I'm guessing you tried it on some version prior to 1.50 or 1.51?
> 
>      >
>      > Besides the file you mentioned, I looked into another file:
>      >
>     http://svn.apache.org/repos/asf/incubator/tuscany/java/das/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/connect/test/ADSEmbeddedConnectionTest.java
>      >
>      > and find a code snippet:
>      >
>      > LdapContext schemaContext = adsEmbeddedConnection.
>      >
>      >                       connect(configuration.
>      >                                       getSchemaPartitionName());
>      >
>      > then what I want to do is:
>      > schemaContext.list("")
> 
>      >
>      > The test case itself relies on many third party jars.
>      > I did not have a maven env, and am trying to configure one.
>      >
>      > Seems it will take me some efforts to find all the dependent
>     jars, and then play with it.
> 
>     Maven should pull them all down for you and install them in your local
>     repository, once you have maven installed.
> 
>     So once you have the mvn command working, you simply cd into the
>     ldap das
>     project root and run
> 
>     "mvn clean install"
> 
>     Maven will download all the dependencies for you.
> 
>     Then run
>     "mvn eclipse:eclipse"
> 
>     at the project root and maven will turn the projects into eclipse
>     projects
>     that you can import and play with.
> 
> 
>      > Where can I find the developer guide?
>      > http://incubator.apache.org/tuscany/starting-with-das.htmll
>     <http://incubator.apache.org/tuscany/starting-with-das.htmll>
>      >  <http://incubator.apache.org/tuscany/starting-with-das.htmll> ?
>      >
>     I wrote some documentation here:
>     https://svn.apache.org/repos/asf/directory/sandbox/oersoy/guides/das.ldap.design.documentation/
> 
>     Still need to finish this up.  I used it to get moving on the DAS
>     and then once I had momentum, I just finished the initial
>     implementation.  It's an eclipse documentation plugin, so just
>     download and drop into your eclipse plugins folder.
> 
>      > If it will not cost you too much energy, would you give me a
>     standalone main file which can start an apacheds server,
>      > and then get the schemaContext, and at last list all the schema
>     entries?
>      >
> 
>     There's also a maven archetype that I have created specifically for
>     this purpose that is located in my Sandbox.
> 
>     http://svn.apache.org/repos/asf/directory/sandbox/oersoy/apacheds.testing.archetype
> 
>     This will enable you to create a project starting point for
>     experimentation.  It does require you to be familiar with maven and
>     maven archetypes.
> 
> 
> 
> 
> -- 
> Spark Shen
> China Software Development Lab, IBM

Re: [ldapserver][schema] How to programmatically extract schema information from a server context

Posted by Spark Shen <sm...@gmail.com>.
One more question:
When executing the test case
org.apache.tuscany.das.ldap.connect.test.ADSEmbeddedConnectionTest, I got
the following exception:
org.apache.directory.server.schema.bootstrap.partition.UniqueResourceException:
Problem locating bootstrap partition database file list.  Be sure there is
exactly one bootstrap partition jar in your classpath.
No resources named
'org/apache/directory/server/schema/bootstrap/partition/DBFILES' located on
classpath
    at
org.apache.directory.server.schema.bootstrap.partition.DbFileListing.getUniqueResource
(DbFileListing.java:139)
    at
org.apache.directory.server.schema.bootstrap.partition.DbFileListing.getUniqueResourceAsStream
(DbFileListing.java:129)
    at
org.apache.directory.server.schema.bootstrap.partition.DbFileListing.init(
DbFileListing.java:82)
    at org.apache.directory.server.schema.bootstrap.partition.DbFileListing
.<init>(DbFileListing.java:51)
    at
org.apache.directory.server.schema.bootstrap.partition.SchemaPartitionExtractor
.<init>(SchemaPartitionExtractor.java:43)
    at org.apache.directory.server.core.DefaultDirectoryService.initialize(
DefaultDirectoryService.java:833)
    at org.apache.directory.server.core.DefaultDirectoryService.startup(
DefaultDirectoryService.java:254)
    at
org.apache.directory.server.core.jndi.AbstractContextFactory.getInitialContext
(AbstractContextFactory.java:124)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java
:667)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java
:247)
    at javax.naming.InitialContext.init(InitialContext.java:223)
    at javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java
:134)
    at org.apache.tuscany.das.ldap.connect.ADSEmbeddedConnection.startup(
ADSEmbeddedConnection.java:159)
    at org.apache.tuscany.das.ldap.connect.ADSEmbeddedConnection.connect(
ADSEmbeddedConnection.java:164)
    at
org.apache.tuscany.das.ldap.connect.test.ADSEmbeddedConnectionTest.testConnect
(ADSEmbeddedConnectionTest.java:25)



2007/11/14, Ole Ersoy <ol...@gmail.com>:
>
>
>
> Spark Shen wrote:
> > And I got the java.lang.UnsupportedOperationException .
> > I am not quite sure whether its my program is wrong or the retrieving
> > schema
> > operation is not supported.
>
> I'm guessing you tried it on some version prior to 1.50 or 1.51?
>
> >
> > Besides the file you mentioned, I looked into another file:
> >
> http://svn.apache.org/repos/asf/incubator/tuscany/java/das/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/connect/test/ADSEmbeddedConnectionTest.java
> >
> > and find a code snippet:
> >
> > LdapContext schemaContext = adsEmbeddedConnection.
> >
> >                       connect(configuration.
> >                                       getSchemaPartitionName());
> >
> > then what I want to do is:
> > schemaContext.list("")
>
> >
> > The test case itself relies on many third party jars.
> > I did not have a maven env, and am trying to configure one.
> >
> > Seems it will take me some efforts to find all the dependent jars, and
> then play with it.
>
> Maven should pull them all down for you and install them in your local
> repository, once you have maven installed.
>
> So once you have the mvn command working, you simply cd into the ldap das
> project root and run
>
> "mvn clean install"
>
> Maven will download all the dependencies for you.
>
> Then run
> "mvn eclipse:eclipse"
>
> at the project root and maven will turn the projects into eclipse projects
> that you can import and play with.
>
>
> > Where can I find the developer guide?
> > http://incubator.apache.org/tuscany/starting-with-das.htmll
> >  <http://incubator.apache.org/tuscany/starting-with-das.htmll> ?
> >
> I wrote some documentation here:
>
> https://svn.apache.org/repos/asf/directory/sandbox/oersoy/guides/das.ldap.design.documentation/
>
> Still need to finish this up.  I used it to get moving on the DAS and then
> once I had momentum, I just finished the initial implementation.  It's an
> eclipse documentation plugin, so just download and drop into your eclipse
> plugins folder.
>
> > If it will not cost you too much energy, would you give me a standalone
> main file which can start an apacheds server,
> > and then get the schemaContext, and at last list all the schema entries?
> >
>
> There's also a maven archetype that I have created specifically for this
> purpose that is located in my Sandbox.
>
>
> http://svn.apache.org/repos/asf/directory/sandbox/oersoy/apacheds.testing.archetype
>
> This will enable you to create a project starting point for
> experimentation.  It does require you to be familiar with maven and maven
> archetypes.
>



-- 
Spark Shen
China Software Development Lab, IBM

Re: [ldapserver][schema] How to programmatically extract schema information from a server context

Posted by Ole Ersoy <ol...@gmail.com>.

Spark Shen wrote:
 > And I got the java.lang.UnsupportedOperationException .
> I am not quite sure whether its my program is wrong or the retrieving 
> schema
> operation is not supported.

I'm guessing you tried it on some version prior to 1.50 or 1.51?

> 
> Besides the file you mentioned, I looked into another file:
> http://svn.apache.org/repos/asf/incubator/tuscany/java/das/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/connect/test/ADSEmbeddedConnectionTest.java
> 
> and find a code snippet:
> 
> LdapContext schemaContext = adsEmbeddedConnection.
> 
> 			connect(configuration.
> 					getSchemaPartitionName());
> 
> then what I want to do is:
> schemaContext.list("")

> 
> The test case itself relies on many third party jars. 
> I did not have a maven env, and am trying to configure one.
> 
> Seems it will take me some efforts to find all the dependent jars, and then play with it. 

Maven should pull them all down for you and install them in your local
repository, once you have maven installed.

So once you have the mvn command working, you simply cd into the ldap das 
project root and run 

"mvn clean install"

Maven will download all the dependencies for you.

Then run 
"mvn eclipse:eclipse"

at the project root and maven will turn the projects into eclipse projects
that you can import and play with.


> Where can I find the developer guide?
> http://incubator.apache.org/tuscany/starting-with-das.htmll
>  <http://incubator.apache.org/tuscany/starting-with-das.htmll> ?
> 
I wrote some documentation here:
https://svn.apache.org/repos/asf/directory/sandbox/oersoy/guides/das.ldap.design.documentation/

Still need to finish this up.  I used it to get moving on the DAS and then once I had momentum, I just finished the initial implementation.  It's an eclipse documentation plugin, so just download and drop into your eclipse plugins folder.

> If it will not cost you too much energy, would you give me a standalone main file which can start an apacheds server, 
> and then get the schemaContext, and at last list all the schema entries? 
> 

There's also a maven archetype that I have created specifically for this purpose that is located in my Sandbox.  

http://svn.apache.org/repos/asf/directory/sandbox/oersoy/apacheds.testing.archetype

This will enable you to create a project starting point for experimentation.  It does require you to be familiar with maven and maven archetypes.

Re: [ldapserver][schema] How to programmatically extract schema information from a server context

Posted by Spark Shen <sm...@gmail.com>.
Indeed, I plan to start a apacheds server, no matter embedded or standalone.
And then construct a context to connect to the server.
Then extract the schema definition from the server.

And I got the java.lang.UnsupportedOperationException.
I am not quite sure whether its my program is wrong or the retrieving schema

operation is not supported.

Besides the file you mentioned, I looked into another file:
http://svn.apache.org/repos/asf/incubator/tuscany/java/das/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/connect/test/ADSEmbeddedConnectionTest.java

and find a code snippet:

LdapContext schemaContext = adsEmbeddedConnection.
			connect(configuration.
					getSchemaPartitionName());

then what I want to do is:
schemaContext.list("")

The test case itself relies on many third party jars. I did not have a
maven env, and am trying to configure one.
Seems it will take me some efforts to find all the dependent jars, and
then play with it.
Where can I find the developer guide?
http://incubator.apache.org/tuscany/starting-with-das.htmll ?

If it will not cost you too much energy, would you give me a
standalone main file which can start an apacheds server,
and then get the schemaContext, and at last list all the schema entries?

Thanks in advance.

2007/11/14, Ole Ersoy <ol...@gmail.com>:
>
> Yes - you nailed it.  Please let me know if you have any detailed
> questions, and I'll do my best to answer.  I think the following test will
> fit what you are looking for:
>
>
> http://svn.apache.org/repos/asf/incubator/tuscany/java/das/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/create/test/EObjectClassCreatorTest.java
>
> Spark Shen wrote:
> > I guess those test cases you mentioned resides in:
> >
> >
> http://svn.apache.org/repos/asf/incubator/tuscany/java/das/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/
> > <
> http://svn.apache.org/repos/asf/incubator/tuscany/java/das/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/
> >
> >
> > 2007/11/5, Ole Ersoy <ole.ersoy@gmail.com <ma...@gmail.com>>:
> >
> >     Hi Spark,
> >
> >     There are a lot of of Schema Unit tests for the LDAP DAS in Apache
> >     Tuscany. They all pass on ADS 1.51, run the server embedded, and
> >     seem to fit with what you have listed below.
> >
> >     Cheers,
> >     - Ole
> >
> >     Emmanuel Lecharny wrote:
> >      > Spark Shen wrote:
> >      >> I noticed 1.5 and 1.0 are two separate product version. I'd like
> to
> >      >> have a try on 1.5. What is the counter-part jar on 1.5?
> >      > 1.5 includes may improvements (performances, stability) and
> >     regarding
> >      > schema, they are now self contained (each objectclass and
> >     attribute is
> >      > an entry in the cn=schema,ou=system partition)
> >      >
> >      > Be aware that we currently don't have described yet how to design
> >     unit
> >      > tests for 1.5, due to lack of time ... (even if the site claims
> so ;)
> >      >> BTW, is my code correct to extract schema info?
> >      > I have no idea, I haven't looked at it yet :)
> >      >
> >      > If you are following the JNDI tutorial
> >      >
> >     (http://java.sun.com/products/jndi/tutorial/ldap/schema/index.html),
> it
> >      > should be OK. Otherwise, if you have a problem, then it may be a
> >     bug,
> >      > and it will deserve a JIRA.
> >      >
> >      > I must also admit I don't have time to copy/paste the code into
> >     my dev
> >      > env to check the code.
> >      >>
> >      >> 2007/11/1, Emmanuel Lecharny < elecharny@gmail.com
> >     <ma...@gmail.com>
> >      >> <mailto:elecharny@gmail.com <ma...@gmail.com>>>:
> >      >>
> >      >>     Spark Shen wrote:
> >      >>     > Hi
> >      >>     >
> >      >>     > I am now using DS server ( apacheds-main-0.9.3.jar) for
> >     writing test
> >      >>     > cases. But I encounter problems when listing schema.
> >      >>     > Problem Description:
> >      >>     > 1. Construct server context
> >      >>     > configuration = new MutableServerStartupConfiguration();
> >      >>     > configuration.setWorkingDirectory(new File(workingDir));
> >      >>     > cleanWorkingDir(configuration.getWorkingDirectory());
> >      >>     > port = AvailablePortFinder.getNextAvailable (1024);
> >      >>     > configuration.setLdapPort(port);
> >      >>     >         // configuration.setShutdownHookEnabled(false);
> >      >>     > serverEnv = new Hashtable<String, Object>(configuration
> >      >>     >                 .toJndiEnvironment());
> >      >>     >
> >      >>     > serverEnv.put(Context.INITIAL_CONTEXT_FACTORY,
> >      >>     >                 ServerContextFactory.class.getName());
> >      >>     >
> >      >>     > serverEnv.put (Context.PROVIDER_URL, "");
> >      >>     >
> >      >>     > serverEnv.put (Context.SECURITY_PRINCIPAL,
> >     "uid=admin,ou=system");
> >      >>     > serverEnv.put(Context.SECURITY_CREDENTIALS , "secret");
> >      >>     > serverEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
> >      >>     > rootDSE = new InitialLdapContext(serverEnv, null);
> >      >>     >
> >      >>     > 2. List schema for this context
> >      >>     >
> >      >>     >             DirContext pairs = super.rootDSE.getSchema
> ("");
> >      >>     >             NamingEnumeration<NameClassPair> ps =
> >      >>     > pairs.list ("objectClasses");
> >      >>     >             while(ps.hasMore()) {
> >      >>     >                 System.out.println(ps.next());
> >      >>     >             }
> >      >>     >
> >      >>     > And ' java.lang.UnsupportedOperationException' was thrown.
> >     I did not
> >      >>     > find a quick instruction
> >      >>     > on how to list schemas, would anyone give a hand?
> >      >>     What about switching to ADS 1.0.2 instead of a badly
> >     outdated 0.9.3
> >      >>     version ?
> >      >>
> >      >>     >
> >      >>     > --
> >      >>     > Spark Shen
> >      >>     > China Software Development Lab, IBM
> >      >>
> >      >>
> >      >>     --
> >      >>     --
> >      >>     cordialement, regards,
> >      >>     Emmanuel Lécharny
> >      >>     www.iktek.com <http://www.iktek.com> < http://www.iktek.com>
> >      >>     directory.apache.org <http://directory.apache.org>
> >     <http://directory.apache.org>
> >      >>
> >      >>
> >      >>
> >      >>
> >      >>
> >      >> --
> >      >> Spark Shen
> >      >> China Software Development Lab, IBM
> >      >
> >      >
> >
> >
> >
> >
> > --
> > Spark Shen
> > China Software Development Lab, IBM
>



-- 
Spark Shen
China Software Development Lab, IBM

Re: [ldapserver][schema] How to programmatically extract schema information from a server context

Posted by Ole Ersoy <ol...@gmail.com>.
Yes - you nailed it.  Please let me know if you have any detailed questions, and I'll do my best to answer.  I think the following test will fit what you are looking for:

http://svn.apache.org/repos/asf/incubator/tuscany/java/das/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/create/test/EObjectClassCreatorTest.java

Spark Shen wrote:
> I guess those test cases you mentioned resides in:
> 
> http://svn.apache.org/repos/asf/incubator/tuscany/java/das/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/ 
> <http://svn.apache.org/repos/asf/incubator/tuscany/java/das/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/>
> 
> 2007/11/5, Ole Ersoy <ole.ersoy@gmail.com <ma...@gmail.com>>:
> 
>     Hi Spark,
> 
>     There are a lot of of Schema Unit tests for the LDAP DAS in Apache
>     Tuscany. They all pass on ADS 1.51, run the server embedded, and
>     seem to fit with what you have listed below.
> 
>     Cheers,
>     - Ole
> 
>     Emmanuel Lecharny wrote:
>      > Spark Shen wrote:
>      >> I noticed 1.5 and 1.0 are two separate product version. I'd like to
>      >> have a try on 1.5. What is the counter-part jar on 1.5?
>      > 1.5 includes may improvements (performances, stability) and
>     regarding
>      > schema, they are now self contained (each objectclass and
>     attribute is
>      > an entry in the cn=schema,ou=system partition)
>      >
>      > Be aware that we currently don't have described yet how to design
>     unit
>      > tests for 1.5, due to lack of time ... (even if the site claims so ;)
>      >> BTW, is my code correct to extract schema info?
>      > I have no idea, I haven't looked at it yet :)
>      >
>      > If you are following the JNDI tutorial
>      >
>     (http://java.sun.com/products/jndi/tutorial/ldap/schema/index.html), it
>      > should be OK. Otherwise, if you have a problem, then it may be a
>     bug,
>      > and it will deserve a JIRA.
>      >
>      > I must also admit I don't have time to copy/paste the code into
>     my dev
>      > env to check the code.
>      >>
>      >> 2007/11/1, Emmanuel Lecharny < elecharny@gmail.com
>     <ma...@gmail.com>
>      >> <mailto:elecharny@gmail.com <ma...@gmail.com>>>:
>      >>
>      >>     Spark Shen wrote:
>      >>     > Hi
>      >>     >
>      >>     > I am now using DS server ( apacheds-main-0.9.3.jar) for
>     writing test
>      >>     > cases. But I encounter problems when listing schema.
>      >>     > Problem Description:
>      >>     > 1. Construct server context
>      >>     > configuration = new MutableServerStartupConfiguration();
>      >>     > configuration.setWorkingDirectory(new File(workingDir));
>      >>     > cleanWorkingDir(configuration.getWorkingDirectory());
>      >>     > port = AvailablePortFinder.getNextAvailable (1024);
>      >>     > configuration.setLdapPort(port);
>      >>     >         // configuration.setShutdownHookEnabled(false);
>      >>     > serverEnv = new Hashtable<String, Object>(configuration
>      >>     >                 .toJndiEnvironment());
>      >>     >
>      >>     > serverEnv.put(Context.INITIAL_CONTEXT_FACTORY,
>      >>     >                 ServerContextFactory.class.getName());
>      >>     >
>      >>     > serverEnv.put (Context.PROVIDER_URL, "");
>      >>     >
>      >>     > serverEnv.put (Context.SECURITY_PRINCIPAL,
>     "uid=admin,ou=system");
>      >>     > serverEnv.put(Context.SECURITY_CREDENTIALS , "secret");
>      >>     > serverEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
>      >>     > rootDSE = new InitialLdapContext(serverEnv, null);
>      >>     >
>      >>     > 2. List schema for this context
>      >>     >
>      >>     >             DirContext pairs = super.rootDSE.getSchema("");
>      >>     >             NamingEnumeration<NameClassPair> ps =
>      >>     > pairs.list ("objectClasses");
>      >>     >             while(ps.hasMore()) {
>      >>     >                 System.out.println(ps.next());
>      >>     >             }
>      >>     >
>      >>     > And ' java.lang.UnsupportedOperationException' was thrown.
>     I did not
>      >>     > find a quick instruction
>      >>     > on how to list schemas, would anyone give a hand?
>      >>     What about switching to ADS 1.0.2 instead of a badly
>     outdated 0.9.3
>      >>     version ?
>      >>
>      >>     >
>      >>     > --
>      >>     > Spark Shen
>      >>     > China Software Development Lab, IBM
>      >>
>      >>
>      >>     --
>      >>     --
>      >>     cordialement, regards,
>      >>     Emmanuel Lécharny
>      >>     www.iktek.com <http://www.iktek.com> < http://www.iktek.com>
>      >>     directory.apache.org <http://directory.apache.org>
>     <http://directory.apache.org>
>      >>
>      >>
>      >>
>      >>
>      >>
>      >> --
>      >> Spark Shen
>      >> China Software Development Lab, IBM
>      >
>      >
> 
> 
> 
> 
> -- 
> Spark Shen
> China Software Development Lab, IBM

Re: [ldapserver][schema] How to programmatically extract schema information from a server context

Posted by Spark Shen <sm...@gmail.com>.
I guess those test cases you mentioned resides in:

http://svn.apache.org/repos/asf/incubator/tuscany/java/das/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/

2007/11/5, Ole Ersoy <ol...@gmail.com>:
>
> Hi Spark,
>
> There are a lot of of Schema Unit tests for the LDAP DAS in Apache
> Tuscany. They all pass on ADS 1.51, run the server embedded, and seem to
> fit with what you have listed below.
>
> Cheers,
> - Ole
>
> Emmanuel Lecharny wrote:
> > Spark Shen wrote:
> >> I noticed 1.5 and 1.0 are two separate product version. I'd like to
> >> have a try on 1.5. What is the counter-part jar on 1.5?
> > 1.5 includes may improvements (performances, stability) and regarding
> > schema, they are now self contained (each objectclass and attribute is
> > an entry in the cn=schema,ou=system partition)
> >
> > Be aware that we currently don't have described yet how to design unit
> > tests for 1.5, due to lack of time ... (even if the site claims so ;)
> >> BTW, is my code correct to extract schema info?
> > I have no idea, I haven't looked at it yet :)
> >
> > If you are following the JNDI tutorial
> > (http://java.sun.com/products/jndi/tutorial/ldap/schema/index.html), it
> > should be OK. Otherwise, if you have a problem, then it may be a bug,
> > and it will deserve a JIRA.
> >
> > I must also admit I don't have time to copy/paste the code into my dev
> > env to check the code.
> >>
> >> 2007/11/1, Emmanuel Lecharny < elecharny@gmail.com
> >> <ma...@gmail.com>>:
> >>
> >>     Spark Shen wrote:
> >>     > Hi
> >>     >
> >>     > I am now using DS server (apacheds-main-0.9.3.jar) for writing
> test
> >>     > cases. But I encounter problems when listing schema.
> >>     > Problem Description:
> >>     > 1. Construct server context
> >>     > configuration = new MutableServerStartupConfiguration();
> >>     > configuration.setWorkingDirectory(new File(workingDir));
> >>     > cleanWorkingDir(configuration.getWorkingDirectory());
> >>     > port = AvailablePortFinder.getNextAvailable (1024);
> >>     > configuration.setLdapPort(port);
> >>     >         // configuration.setShutdownHookEnabled(false);
> >>     > serverEnv = new Hashtable<String, Object>(configuration
> >>     >                 .toJndiEnvironment());
> >>     >
> >>     > serverEnv.put(Context.INITIAL_CONTEXT_FACTORY,
> >>     >                 ServerContextFactory.class.getName());
> >>     >
> >>     > serverEnv.put(Context.PROVIDER_URL, "");
> >>     >
> >>     > serverEnv.put (Context.SECURITY_PRINCIPAL,
> "uid=admin,ou=system");
> >>     > serverEnv.put(Context.SECURITY_CREDENTIALS , "secret");
> >>     > serverEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
> >>     > rootDSE = new InitialLdapContext(serverEnv, null);
> >>     >
> >>     > 2. List schema for this context
> >>     >
> >>     >             DirContext pairs = super.rootDSE.getSchema("");
> >>     >             NamingEnumeration<NameClassPair> ps =
> >>     > pairs.list("objectClasses");
> >>     >             while(ps.hasMore()) {
> >>     >                 System.out.println(ps.next());
> >>     >             }
> >>     >
> >>     > And 'java.lang.UnsupportedOperationException' was thrown. I did
> not
> >>     > find a quick instruction
> >>     > on how to list schemas, would anyone give a hand?
> >>     What about switching to ADS 1.0.2 instead of a badly outdated 0.9.3
> >>     version ?
> >>
> >>     >
> >>     > --
> >>     > Spark Shen
> >>     > China Software Development Lab, IBM
> >>
> >>
> >>     --
> >>     --
> >>     cordialement, regards,
> >>     Emmanuel Lécharny
> >>     www.iktek.com <http://www.iktek.com>
> >>     directory.apache.org <http://directory.apache.org>
> >>
> >>
> >>
> >>
> >>
> >> --
> >> Spark Shen
> >> China Software Development Lab, IBM
> >
> >
>



-- 
Spark Shen
China Software Development Lab, IBM

Re: [ldapserver][schema] How to programmatically extract schema information from a server context

Posted by Ole Ersoy <ol...@gmail.com>.
Hi Spark,

There are a lot of of Schema Unit tests for the LDAP DAS in Apache Tuscany. They all pass on ADS 1.51, run the server embedded, and seem to fit with what you have listed below.

Cheers,
- Ole

Emmanuel Lecharny wrote:
> Spark Shen wrote:
>> I noticed 1.5 and 1.0 are two separate product version. I'd like to 
>> have a try on 1.5. What is the counter-part jar on 1.5?
> 1.5 includes may improvements (performances, stability) and regarding 
> schema, they are now self contained (each objectclass and attribute is 
> an entry in the cn=schema,ou=system partition)
> 
> Be aware that we currently don't have described yet how to design unit 
> tests for 1.5, due to lack of time ... (even if the site claims so ;)
>> BTW, is my code correct to extract schema info?
> I have no idea, I haven't looked at it yet :)
> 
> If you are following the JNDI tutorial 
> (http://java.sun.com/products/jndi/tutorial/ldap/schema/index.html), it 
> should be OK. Otherwise, if you have a problem, then it may be a bug, 
> and it will deserve a JIRA.
> 
> I must also admit I don't have time to copy/paste the code into my dev 
> env to check the code.
>>
>> 2007/11/1, Emmanuel Lecharny < elecharny@gmail.com 
>> <ma...@gmail.com>>:
>>
>>     Spark Shen wrote:
>>     > Hi
>>     >
>>     > I am now using DS server (apacheds-main-0.9.3.jar) for writing test
>>     > cases. But I encounter problems when listing schema.
>>     > Problem Description:
>>     > 1. Construct server context
>>     > configuration = new MutableServerStartupConfiguration();
>>     > configuration.setWorkingDirectory(new File(workingDir));
>>     > cleanWorkingDir(configuration.getWorkingDirectory());
>>     > port = AvailablePortFinder.getNextAvailable (1024);
>>     > configuration.setLdapPort(port);
>>     >         // configuration.setShutdownHookEnabled(false);
>>     > serverEnv = new Hashtable<String, Object>(configuration
>>     >                 .toJndiEnvironment());
>>     >
>>     > serverEnv.put(Context.INITIAL_CONTEXT_FACTORY,
>>     >                 ServerContextFactory.class.getName());
>>     >
>>     > serverEnv.put(Context.PROVIDER_URL, "");
>>     >
>>     > serverEnv.put (Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
>>     > serverEnv.put(Context.SECURITY_CREDENTIALS , "secret");
>>     > serverEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
>>     > rootDSE = new InitialLdapContext(serverEnv, null);
>>     >
>>     > 2. List schema for this context
>>     >
>>     >             DirContext pairs = super.rootDSE.getSchema("");
>>     >             NamingEnumeration<NameClassPair> ps =
>>     > pairs.list("objectClasses");
>>     >             while(ps.hasMore()) {
>>     >                 System.out.println(ps.next());
>>     >             }
>>     >
>>     > And 'java.lang.UnsupportedOperationException' was thrown. I did not
>>     > find a quick instruction
>>     > on how to list schemas, would anyone give a hand?
>>     What about switching to ADS 1.0.2 instead of a badly outdated 0.9.3
>>     version ?
>>
>>     >
>>     > --
>>     > Spark Shen
>>     > China Software Development Lab, IBM
>>
>>
>>     --
>>     --
>>     cordialement, regards,
>>     Emmanuel Lécharny
>>     www.iktek.com <http://www.iktek.com>
>>     directory.apache.org <http://directory.apache.org>
>>
>>
>>
>>
>>
>> -- 
>> Spark Shen
>> China Software Development Lab, IBM 
> 
> 

Re: [ldapserver][schema] How to programmatically extract schema information from a server context

Posted by Emmanuel Lecharny <el...@gmail.com>.
Spark Shen wrote:
> I noticed 1.5 and 1.0 are two separate product version. I'd like to 
> have a try on 1.5. What is the counter-part jar on 1.5?
1.5 includes may improvements (performances, stability) and regarding 
schema, they are now self contained (each objectclass and attribute is 
an entry in the cn=schema,ou=system partition)

Be aware that we currently don't have described yet how to design unit 
tests for 1.5, due to lack of time ... (even if the site claims so ;)
> BTW, is my code correct to extract schema info?
I have no idea, I haven't looked at it yet :)

If you are following the JNDI tutorial 
(http://java.sun.com/products/jndi/tutorial/ldap/schema/index.html), it 
should be OK. Otherwise, if you have a problem, then it may be a bug, 
and it will deserve a JIRA.

I must also admit I don't have time to copy/paste the code into my dev 
env to check the code.
>
> 2007/11/1, Emmanuel Lecharny < elecharny@gmail.com 
> <ma...@gmail.com>>:
>
>     Spark Shen wrote:
>     > Hi
>     >
>     > I am now using DS server (apacheds-main-0.9.3.jar) for writing test
>     > cases. But I encounter problems when listing schema.
>     > Problem Description:
>     > 1. Construct server context
>     > configuration = new MutableServerStartupConfiguration();
>     > configuration.setWorkingDirectory(new File(workingDir));
>     > cleanWorkingDir(configuration.getWorkingDirectory());
>     > port = AvailablePortFinder.getNextAvailable (1024);
>     > configuration.setLdapPort(port);
>     >         // configuration.setShutdownHookEnabled(false);
>     > serverEnv = new Hashtable<String, Object>(configuration
>     >                 .toJndiEnvironment());
>     >
>     > serverEnv.put(Context.INITIAL_CONTEXT_FACTORY,
>     >                 ServerContextFactory.class.getName());
>     >
>     > serverEnv.put(Context.PROVIDER_URL, "");
>     >
>     > serverEnv.put (Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
>     > serverEnv.put(Context.SECURITY_CREDENTIALS , "secret");
>     > serverEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
>     > rootDSE = new InitialLdapContext(serverEnv, null);
>     >
>     > 2. List schema for this context
>     >
>     >             DirContext pairs = super.rootDSE.getSchema("");
>     >             NamingEnumeration<NameClassPair> ps =
>     > pairs.list("objectClasses");
>     >             while(ps.hasMore()) {
>     >                 System.out.println(ps.next());
>     >             }
>     >
>     > And 'java.lang.UnsupportedOperationException' was thrown. I did not
>     > find a quick instruction
>     > on how to list schemas, would anyone give a hand?
>     What about switching to ADS 1.0.2 instead of a badly outdated 0.9.3
>     version ?
>
>     >
>     > --
>     > Spark Shen
>     > China Software Development Lab, IBM
>
>
>     --
>     --
>     cordialement, regards,
>     Emmanuel Lécharny
>     www.iktek.com <http://www.iktek.com>
>     directory.apache.org <http://directory.apache.org>
>
>
>
>
>
> -- 
> Spark Shen
> China Software Development Lab, IBM 


-- 
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org



Re: [ldapserver][schema] How to programmatically extract schema information from a server context

Posted by Spark Shen <sm...@gmail.com>.
I noticed 1.5 and 1.0 are two separate product version. I'd like to have a
try on 1.5. What is the counter-part jar on 1.5?
BTW, is my code correct to extract schema info?

2007/11/1, Emmanuel Lecharny <el...@gmail.com>:
>
> Spark Shen wrote:
> > Hi
> >
> > I am now using DS server (apacheds-main-0.9.3.jar) for writing test
> > cases. But I encounter problems when listing schema.
> > Problem Description:
> > 1. Construct server context
> > configuration = new MutableServerStartupConfiguration();
> > configuration.setWorkingDirectory(new File(workingDir));
> > cleanWorkingDir(configuration.getWorkingDirectory());
> > port = AvailablePortFinder.getNextAvailable(1024);
> > configuration.setLdapPort(port);
> >         // configuration.setShutdownHookEnabled(false);
> > serverEnv = new Hashtable<String, Object>(configuration
> >                 .toJndiEnvironment());
> >
> > serverEnv.put(Context.INITIAL_CONTEXT_FACTORY,
> >                 ServerContextFactory.class.getName());
> >
> > serverEnv.put(Context.PROVIDER_URL, "");
> >
> > serverEnv.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
> > serverEnv.put(Context.SECURITY_CREDENTIALS , "secret");
> > serverEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
> > rootDSE = new InitialLdapContext(serverEnv, null);
> >
> > 2. List schema for this context
> >
> >             DirContext pairs = super.rootDSE.getSchema("");
> >             NamingEnumeration<NameClassPair> ps =
> > pairs.list("objectClasses");
> >             while(ps.hasMore()) {
> >                 System.out.println(ps.next());
> >             }
> >
> > And 'java.lang.UnsupportedOperationException' was thrown. I did not
> > find a quick instruction
> > on how to list schemas, would anyone give a hand?
> What about switching to ADS 1.0.2 instead of a badly outdated 0.9.3
> version ?
>
> >
> > --
> > Spark Shen
> > China Software Development Lab, IBM
>
>
> --
> --
> cordialement, regards,
> Emmanuel Lécharny
> www.iktek.com
> directory.apache.org
>
>
>


-- 
Spark Shen
China Software Development Lab, IBM

Re: [ldapserver][schema] How to programmatically extract schema information from a server context

Posted by Spark Shen <sm...@gmail.com>.
2007/11/1, Emmanuel Lecharny <el...@gmail.com>:
>
> Spark Shen wrote:
> > Hi
> >
> > I am now using DS server (apacheds-main-0.9.3.jar) for writing test
> > cases. But I encounter problems when listing schema.
> > Problem Description:
> > 1. Construct server context
> > configuration = new MutableServerStartupConfiguration();
> > configuration.setWorkingDirectory(new File(workingDir));
> > cleanWorkingDir(configuration.getWorkingDirectory());
> > port = AvailablePortFinder.getNextAvailable(1024);
> > configuration.setLdapPort(port);
> >         // configuration.setShutdownHookEnabled(false);
> > serverEnv = new Hashtable<String, Object>(configuration
> >                 .toJndiEnvironment());
> >
> > serverEnv.put(Context.INITIAL_CONTEXT_FACTORY,
> >                 ServerContextFactory.class.getName());
> >
> > serverEnv.put(Context.PROVIDER_URL, "");
> >
> > serverEnv.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
> > serverEnv.put(Context.SECURITY_CREDENTIALS , "secret");
> > serverEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
> > rootDSE = new InitialLdapContext(serverEnv, null);
> >
> > 2. List schema for this context
> >
> >             DirContext pairs = super.rootDSE.getSchema("");
> >             NamingEnumeration<NameClassPair> ps =
> > pairs.list("objectClasses");
> >             while(ps.hasMore()) {
> >                 System.out.println(ps.next());
> >             }
> >
> > And 'java.lang.UnsupportedOperationException' was thrown. I did not
> > find a quick instruction
> > on how to list schemas, would anyone give a hand?
> What about switching to ADS 1.0.2 instead of a badly outdated 0.9.3
> version ?


:-) Ok, I will try.

>
> > --
> > Spark Shen
> > China Software Development Lab, IBM
>
>
> --
> --
> cordialement, regards,
> Emmanuel Lécharny
> www.iktek.com
> directory.apache.org
>
>
>


-- 
Spark Shen
China Software Development Lab, IBM

Re: [ldapserver][schema] How to programmatically extract schema information from a server context

Posted by Emmanuel Lecharny <el...@gmail.com>.
Spark Shen wrote:
> Hi
>
> I am now using DS server (apacheds-main-0.9.3.jar) for writing test 
> cases. But I encounter problems when listing schema.
> Problem Description:
> 1. Construct server context
> configuration = new MutableServerStartupConfiguration();
> configuration.setWorkingDirectory(new File(workingDir));
> cleanWorkingDir(configuration.getWorkingDirectory());
> port = AvailablePortFinder.getNextAvailable(1024);
> configuration.setLdapPort(port);
>         // configuration.setShutdownHookEnabled(false);
> serverEnv = new Hashtable<String, Object>(configuration
>                 .toJndiEnvironment());
>
> serverEnv.put(Context.INITIAL_CONTEXT_FACTORY,
>                 ServerContextFactory.class.getName());
>
> serverEnv.put(Context.PROVIDER_URL, "");
>
> serverEnv.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
> serverEnv.put(Context.SECURITY_CREDENTIALS , "secret");
> serverEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
> rootDSE = new InitialLdapContext(serverEnv, null);
>
> 2. List schema for this context
>
>             DirContext pairs = super.rootDSE.getSchema("");
>             NamingEnumeration<NameClassPair> ps = 
> pairs.list("objectClasses");
>             while(ps.hasMore()) {
>                 System.out.println(ps.next());
>             }
>
> And 'java.lang.UnsupportedOperationException' was thrown. I did not 
> find a quick instruction
> on how to list schemas, would anyone give a hand?
What about switching to ADS 1.0.2 instead of a badly outdated 0.9.3 
version ?

>
> -- 
> Spark Shen
> China Software Development Lab, IBM 


-- 
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org