}
}
browserConnection.getRootDSE().setChildrenInitialized( false );
// load all user attributes
ISearch search = new Search( null, browserConnection, LdapDN.EMPTY_LDAPDN, ISearch.FILTER_TRUE, new String[]
{ ISearch.ALL_USER_ATTRIBUTES }, SearchScope.OBJECT, 0, 0, Connection.AliasDereferencingMethod.NEVER,
Connection.ReferralHandlingMethod.IGNORE, false, null );
SearchJob.searchAndUpdateModel( browserConnection, search, monitor );
// load well-known Root DSE attributes and operational attributes
search = new Search( null, browserConnection, LdapDN.EMPTY_LDAPDN, ISearch.FILTER_TRUE, ROOT_DSE_ATTRIBUTES,
SearchScope.OBJECT, 0, 0, Connection.AliasDereferencingMethod.NEVER,
Connection.ReferralHandlingMethod.IGNORE, false, null );
SearchJob.searchAndUpdateModel( browserConnection, search, monitor );
// the list of entries under the Root DSE
Map<LdapDN, IEntry> rootDseEntries = new HashMap<LdapDN, IEntry>();
// 1st: add base DNs, either the specified or from the namingContexts attribute
if ( !browserConnection.isFetchBaseDNs() && browserConnection.getBaseDN() != null
&& !"".equals( browserConnection.getBaseDN().toString() ) )
{
// only add the specified base DN
try
{
LdapDN dn = browserConnection.getBaseDN();
IEntry entry = browserConnection.getEntryFromCache( dn );
if ( entry == null )
{
entry = new BaseDNEntry( new LdapDN( dn ), browserConnection );
browserConnection.cacheEntry( entry );
}
rootDseEntries.put( dn, entry );
}
catch ( InvalidNameException e )
{
monitor.reportError( BrowserCoreMessages.model__error_setting_base_dn, e );
}
}
else
{
// get base DNs from namingContexts attribute
Set<String> namingContextSet = new HashSet<String>();
IAttribute attribute = browserConnection.getRootDSE().getAttribute(
IRootDSE.ROOTDSE_ATTRIBUTE_NAMINGCONTEXTS );
if ( attribute != null )
{
String[] values = attribute.getStringValues();
for ( int i = 0; i < values.length; i++ )
{
namingContextSet.add( values[i] );
}
}
for ( String namingContext : namingContextSet )
{
if ( !"".equals( namingContext ) ) { //$NON-NLS-1$
try
{
LdapDN dn = new LdapDN( namingContext );
IEntry entry = browserConnection.getEntryFromCache( dn );
if ( entry == null )
{
entry = new BaseDNEntry( new LdapDN( dn ), browserConnection );
browserConnection.cacheEntry( entry );
}
rootDseEntries.put( dn, entry );
}
catch ( InvalidNameException 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
search = new Search( null, browserConnection, LdapDN.EMPTY_LDAPDN, ISearch.FILTER_TRUE,
ISearch.NO_ATTRIBUTES, SearchScope.ONELEVEL, 0, 0, Connection.AliasDereferencingMethod.NEVER,
Connection.ReferralHandlingMethod.IGNORE, false, null );
SearchJob.searchAndUpdateModel( browserConnection, search, monitor );
ISearchResult[] results = search.getSearchResults();
for ( ISearchResult searchResult : results )
{
IEntry entry = searchResult.getEntry();
rootDseEntries.put( entry.getDn(), entry );
}