in plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/InitializeRootDSERunnable.java [167:367]
public static synchronized void loadRootDSE( IBrowserConnection browserConnection, StudioProgressMonitor monitor )
{
// clear old children
InitializeChildrenRunnable.clearCaches( browserConnection.getRootDSE(), true );
// delete old attributes
IAttribute[] oldAttributes = browserConnection.getRootDSE().getAttributes();
if ( oldAttributes != null )
{
for ( IAttribute oldAttribute : oldAttributes )
{
browserConnection.getRootDSE().deleteAttribute( oldAttribute );
}
}
// load well-known Root DSE attributes and operational attributes
ISearch search = new Search( null, browserConnection, Dn.EMPTY_DN, ISearch.FILTER_TRUE,
ROOT_DSE_ATTRIBUTES, SearchScope.OBJECT, 0, 0, Connection.AliasDereferencingMethod.NEVER,
Connection.ReferralHandlingMethod.IGNORE, false, null, false );
SearchRunnable.searchAndUpdateModel( browserConnection, search, monitor );
// Load all user attributes. This is done because the BEA "LDAP server" (so called) is stupid
// enough not to accept searches where "+" and "*" are provided on the list of parameters.
// We have to do two searches...
search = new Search( null, browserConnection, Dn.EMPTY_DN, ISearch.FILTER_TRUE, new String[]
{ SchemaConstants.ALL_USER_ATTRIBUTES }, SearchScope.OBJECT, 0, 0,
Connection.AliasDereferencingMethod.NEVER, Connection.ReferralHandlingMethod.IGNORE, false, null, false );
SearchRunnable.searchAndUpdateModel( browserConnection, search, monitor );
// the list of entries under the Root DSE
Map<Dn, IEntry> rootDseEntries = new HashMap<Dn, IEntry>();
// 1st: add base DNs, either the specified or from the namingContexts attribute
if ( !browserConnection.isFetchBaseDNs() && browserConnection.getBaseDN() != null
&& !"".equals( browserConnection.getBaseDN().toString() ) ) //$NON-NLS-1$
{
// only add the specified base Dn
Dn dn = browserConnection.getBaseDN();
IEntry entry = browserConnection.getEntryFromCache( dn );
if ( entry == null )
{
entry = new BaseDNEntry( dn, browserConnection );
browserConnection.cacheEntry( entry );
}
rootDseEntries.put( dn, entry );
}
else
{
// get base DNs from namingContexts attribute
Set<String> namingContextSet = new HashSet<String>();
IAttribute attribute = browserConnection.getRootDSE().getAttribute( SchemaConstants.NAMING_CONTEXTS_AT );
if ( attribute != null )
{
String[] values = attribute.getStringValues();
for ( int i = 0; i < values.length; i++ )
{
namingContextSet.add( values[i] );
}
}
if ( !namingContextSet.isEmpty() )
{
for ( String namingContext : namingContextSet )
{
if ( namingContext.length() > 0 && namingContext.charAt( namingContext.length() - 1 ) == '\u0000' )
{
namingContext = namingContext.substring( 0, namingContext.length() - 1 );
}
if ( !"".equals( namingContext ) ) //$NON-NLS-1$
{
try
{
Dn dn = new Dn( namingContext );
IEntry entry = browserConnection.getEntryFromCache( dn );
if ( entry == null )
{
entry = new BaseDNEntry( dn, browserConnection );
browserConnection.cacheEntry( entry );
}
rootDseEntries.put( dn, entry );
}
catch ( LdapInvalidDnException e )
{
monitor.reportError( BrowserCoreMessages.model__error_setting_base_dn, e );
}
}
else
{
// special handling of empty namingContext (Novell eDirectory):
// perform a one-level search and add all result DNs to the set
searchRootDseEntries( browserConnection, rootDseEntries, monitor );
}
}
}
else
{
// special handling of non-existing namingContexts attribute (Oracle Internet Directory)
// perform a one-level search and add all result DNs to the set
searchRootDseEntries( browserConnection, rootDseEntries, monitor );
}
}
// 2nd: add schema sub-entry
IEntry[] schemaEntries = getDirectoryMetadataEntries( browserConnection, SchemaConstants.SUBSCHEMA_SUBENTRY_AT );
for ( IEntry entry : schemaEntries )
{
if ( entry instanceof DirectoryMetadataEntry )
{
( ( DirectoryMetadataEntry ) entry ).setSchemaEntry( true );
}
rootDseEntries.put( entry.getDn(), entry );
}
// get other meta data entries
IAttribute[] rootDseAttributes = browserConnection.getRootDSE().getAttributes();
if ( rootDseAttributes != null )
{
for ( IAttribute attribute : rootDseAttributes )
{
IEntry[] metadataEntries = getDirectoryMetadataEntries( browserConnection, attribute.getDescription() );
for ( IEntry entry : metadataEntries )
{
rootDseEntries.put( entry.getDn(), entry );
}
}
}
// try to init entries
StudioProgressMonitor dummyMonitor = new StudioProgressMonitor( monitor );
for ( IEntry entry : rootDseEntries.values() )
{
initBaseEntry( entry, dummyMonitor );
}
// set flags
browserConnection.getRootDSE().setHasMoreChildren( false );
browserConnection.getRootDSE().setAttributesInitialized( true );
browserConnection.getRootDSE().setInitOperationalAttributes( true );
browserConnection.getRootDSE().setChildrenInitialized( true );
browserConnection.getRootDSE().setHasChildrenHint( true );
browserConnection.getRootDSE().setDirectoryEntry( true );
// Set detected connection properties
DetectedConnectionProperties detectedConnectionProperties = browserConnection.getConnection()
.getDetectedConnectionProperties();
IAttribute vendorNameAttribute = browserConnection.getRootDSE().getAttribute( "vendorName" ); //$NON-NLS-1$
if ( ( vendorNameAttribute != null ) && ( vendorNameAttribute.getValueSize() > 0 ) )
{
detectedConnectionProperties.setVendorName( vendorNameAttribute.getStringValue() );
}
IAttribute vendorVersionAttribute = browserConnection.getRootDSE().getAttribute( "vendorVersion" ); //$NON-NLS-1$
if ( ( vendorVersionAttribute != null ) && ( vendorVersionAttribute.getValueSize() > 0 ) )
{
detectedConnectionProperties.setVendorVersion( vendorVersionAttribute.getStringValue() );
}
IAttribute supportedControlAttribute = browserConnection.getRootDSE().getAttribute( "supportedControl" ); //$NON-NLS-1$
if ( ( supportedControlAttribute != null ) && ( supportedControlAttribute.getValueSize() > 0 ) )
{
detectedConnectionProperties.setSupportedControls( Arrays.asList( supportedControlAttribute
.getStringValues() ) );
}
IAttribute supportedExtensionAttribute = browserConnection.getRootDSE().getAttribute( "supportedExtension" ); //$NON-NLS-1$
if ( ( supportedExtensionAttribute != null ) && ( supportedExtensionAttribute.getValueSize() > 0 ) )
{
detectedConnectionProperties.setSupportedExtensions( Arrays.asList( supportedExtensionAttribute
.getStringValues() ) );
}
IAttribute supportedFeaturesAttribute = browserConnection.getRootDSE().getAttribute( "supportedFeatures" ); //$NON-NLS-1$
if ( ( supportedFeaturesAttribute != null ) && ( supportedFeaturesAttribute.getValueSize() > 0 ) )
{
detectedConnectionProperties.setSupportedFeatures( Arrays.asList( supportedFeaturesAttribute
.getStringValues() ) );
}
detectedConnectionProperties
.setServerType( ServerTypeDetector.detectServerType( browserConnection.getRootDSE() ) );
ConnectionCorePlugin.getDefault().getConnectionManager()
.connectionUpdated( browserConnection.getConnection() );
}