in apacheds-archetype-webapp/src/main/resources/archetype-resources/src/main/java/RootDseServlet.java [56:97]
protected void doGet( HttpServletRequest req, HttpServletResponse resp ) throws ServletException
{
try
{
resp.setContentType( "text/plain" );
PrintWriter out = resp.getWriter();
out.println( "*** ApacheDS RootDSE ***\n" );
DirContext ctx = new InitialDirContext( this.createEnv() );
SearchControls ctls = new SearchControls();
ctls.setReturningAttributes( new String[]
{ "*", "+" } );
ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
NamingEnumeration<SearchResult> result = ctx.search( "", "(objectClass=*)", ctls );
if ( result.hasMore() )
{
SearchResult entry = result.next();
Attributes as = entry.getAttributes();
NamingEnumeration<String> ids = as.getIDs();
while ( ids.hasMore() )
{
String id = ids.next();
Attribute attr = as.get( id );
for ( int i = 0; i < attr.size(); ++i )
{
out.println( id + ": " + attr.get( i ) );
}
}
}
ctx.close();
out.flush();
}
catch ( Exception e )
{
throw new ServletException( e );
}
}