{
boolean typeDetected = false;
// check OpenLDAP
IAttribute ocAttribute = connection.getRootDSE().getAttribute( "objectClass" );
if ( ocAttribute != null )
{
for ( int i = 0; i < ocAttribute.getStringValues().length; i++ )
{
if ( "OpenLDAProotDSE".equals( ocAttribute.getStringValues()[i] ) )
{
IAttribute ccAttribute = connection.getRootDSE().getAttribute( "configContext" );
if ( ccAttribute != null )
{
typeText.setText( "OpenLDAP 2.3" );
typeDetected = true;
}
if ( !typeDetected )
{
IAttribute scAttribute = connection.getRootDSE().getAttribute( "supportedControl" );
if ( scAttribute != null )
{
for ( int sci = 0; sci < scAttribute.getStringValues().length; sci++ )
{
// if("1.2.840.113556.1.4.319".equals(scAttribute.getStringValues()[sci]))
// {
if ( "2.16.840.1.113730.3.4.18".equals( scAttribute.getStringValues()[sci] ) )
{
typeText.setText( "OpenLDAP 2.2" );
typeDetected = true;
}
}
}
}
if ( !typeDetected )
{
IAttribute seAttribute = connection.getRootDSE().getAttribute( "supportedExtension" );
if ( seAttribute != null )
{
for ( int sei = 0; sei < seAttribute.getStringValues().length; sei++ )
{
if ( "1.3.6.1.4.1.4203.1.11.3".equals( seAttribute.getStringValues()[sei] ) )
{
typeText.setText( "OpenLDAP 2.1" );
typeDetected = true;
}
}
}
}
if ( !typeDetected )
{
IAttribute sfAttribute = connection.getRootDSE().getAttribute( "supportedFeatures" );
if ( sfAttribute != null )
{
for ( int sfi = 0; sfi < sfAttribute.getStringValues().length; sfi++ )
{
if ( "1.3.6.1.4.1.4203.1.5.4".equals( sfAttribute.getStringValues()[sfi] ) )
{
typeText.setText( "OpenLDAP 2.0" );
typeDetected = true;
}
}
}
}
if ( !typeDetected )
{
typeText.setText( "OpenLDAP" );
typeDetected = true;
}
}
}
}
// check Siemens DirX
IAttribute ssseAttribute = connection.getRootDSE().getAttribute( "subSchemaSubentry" );
if ( ssseAttribute != null )
{
for ( int i = 0; i < ssseAttribute.getStringValues().length; i++ )
{
if ( "cn=LDAPGlobalSchemaSubentry".equals( ssseAttribute.getStringValues()[i] ) )
{
typeText.setText( "Siemens DirX" );
}
}
}
// check active directory
IAttribute rdncAttribute = connection.getRootDSE().getAttribute( "rootDomainNamingContext" );
if ( rdncAttribute != null )
{
IAttribute ffAttribute = connection.getRootDSE().getAttribute( "forestFunctionality" );
if ( ffAttribute != null )
{
typeText.setText( "Microsoft Active Directory 2003" );
}
else
{
typeText.setText( "Microsoft Active Directory 2000" );
}
}
// check Novell eDirectory / Sun Directory Server / Netscape
// Directory Server
IAttribute vnAttribute = connection.getRootDSE().getAttribute( "vendorName" );
IAttribute vvAttribute = connection.getRootDSE().getAttribute( "vendorVersion" );
if ( vnAttribute != null && vnAttribute.getStringValues().length > 0 && vvAttribute != null
&& vvAttribute.getStringValues().length > 0 )
{
if ( vnAttribute.getStringValues()[0].indexOf( "Novell" ) > -1
|| vvAttribute.getStringValues()[0].indexOf( "eDirectory" ) > -1 )
{
typeText.setText( "Novell eDirectory" );
}
if ( vnAttribute.getStringValues()[0].indexOf( "Sun" ) > -1
|| vvAttribute.getStringValues()[0].indexOf( "Sun" ) > -1 )
{
typeText.setText( "Sun Directory Server" );
}
if ( vnAttribute.getStringValues()[0].indexOf( "Netscape" ) > -1
|| vvAttribute.getStringValues()[0].indexOf( "Netscape" ) > -1 )
{
typeText.setText( "Netscape Directory Server" );
}
}
}