@Override
	public ILDAPRetrievalService buildService() throws LDAPServiceCreationException {
		ILDAPRetrievalService service = null;

		if (this.getLDAPResource().getServerVendor().equals(LDAPServiceProviderType.APACHEDS_SERVICE_PROVIDER.name())) {
			try {
				service = new org.sharpsw.ldap.services.apacheds.RetrievalServiceImpl(this.getConnectionFactory().getConnection(this.getLDAPResource()), this.getLDAPResource());
			} catch (LDAPException exception) {
				throw new LDAPServiceCreationException("Error when creating the admin service", exception);
			}
		} else if (this.getLDAPResource().getServerVendor().equals(LDAPServiceProviderType.MS_ACTIVE_DIRECTORY_2003_SERVICE_PROVIDER.name())) {
			try {
				service = new org.sharpsw.ldap.services.msad.RetrievalServiceImpl(this.getConnectionFactory().getConnection(this.getLDAPResource()), this.getLDAPResource());
			} catch (LDAPException exception) {
				throw new LDAPServiceCreationException("Error when creating the service", exception);
			}
		} else if (this.getLDAPResource().getServerVendor().equals(LDAPServiceProviderType.OPEN_LDAP_SERVICE_PROVIDER.name())) {
			try {
				service = new org.sharpsw.ldap.services.openldap.RetrievalServiceImpl(this.getConnectionFactory().getConnection(this.getLDAPResource()), this.getLDAPResource(), new DistinguishedNameBuilder());
			} catch (LDAPException exception) {
				throw new LDAPServiceCreationException("Error when creating the service", exception);
			}
		} else {
			StringBuffer buffer = new StringBuffer();
			buffer.append("Invalid service provider supplied: ").append(this.getLDAPResource().getServerVendor());
			throw new LDAPServiceCreationException(buffer.toString());
		}
		return service;
	}