本文整理了Java中org.apache.directory.ldap.client.api.LdapConnection.search()
方法的一些代码示例,展示了LdapConnection.search()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LdapConnection.search()
方法的具体详情如下:
包路径:org.apache.directory.ldap.client.api.LdapConnection
类名称:LdapConnection
方法名:search
[英]Do a search, on the base object, using the given filter and scope. The SearchRequest parameters default to
代码示例来源:origin: HubSpot/Singularity
final EntryCursor userCursor = connection.search(configuration.getUserBaseDN(),
String.format(configuration.getUserFilter(), user),
SearchScope.ONELEVEL, configuration.getUserNameAttribute(), configuration.getUserEmailAttribute());
final EntryCursor cursor = connection.search(configuration.getGroupBaseDN(),
String.format(configuration.getGroupFilter(), user),
configuration.getGroupSearchScope(), configuration.getGroupNameAttribute());
代码示例来源:origin: org.apache.directory.api/api-ldap-client-all
/**
* {@inheritDoc}
*/
@Override
public EntryCursor search( String baseDn, String filter, SearchScope scope, String... attributes )
throws LdapException
{
return connection.search( baseDn, filter, scope, attributes );
}
代码示例来源:origin: org.apache.directory.api/api-all
/**
* {@inheritDoc}
*/
@Override
public SearchCursor search( SearchRequest searchRequest ) throws LdapException
{
return connection.search( searchRequest );
}
代码示例来源:origin: org.apache.directory.api/api-ldap-client-all
/**
* {@inheritDoc}
*/
@Override
public SearchCursor search( SearchRequest searchRequest ) throws LdapException
{
return connection.search( searchRequest );
}
代码示例来源:origin: org.apache.directory.api/api-all
/**
* {@inheritDoc}
*/
@Override
public EntryCursor search( Dn baseDn, String filter, SearchScope scope, String... attributes )
throws LdapException
{
return connection.search( baseDn, filter, scope, attributes );
}
代码示例来源:origin: org.apache.directory.api/api-ldap-client-api
/**
* {@inheritDoc}
*/
@Override
public EntryCursor search( String baseDn, String filter, SearchScope scope, String... attributes )
throws LdapException
{
return connection.search( baseDn, filter, scope, attributes );
}
代码示例来源:origin: org.apache.directory.api/api-ldap-client-all
/**
* {@inheritDoc}
*/
@Override
public EntryCursor search( Dn baseDn, String filter, SearchScope scope, String... attributes )
throws LdapException
{
return connection.search( baseDn, filter, scope, attributes );
}
代码示例来源:origin: org.apache.directory.api/api-ldap-client-api
/**
* {@inheritDoc}
*/
@Override
public EntryCursor search( Dn baseDn, String filter, SearchScope scope, String... attributes )
throws LdapException
{
return connection.search( baseDn, filter, scope, attributes );
}
代码示例来源:origin: org.apache.directory.api/api-all
/**
* {@inheritDoc}
*/
@Override
public EntryCursor search( String baseDn, String filter, SearchScope scope, String... attributes )
throws LdapException
{
return connection.search( baseDn, filter, scope, attributes );
}
代码示例来源:origin: org.apache.directory.api/api-ldap-client-api
/**
* {@inheritDoc}
*/
@Override
public SearchCursor search( SearchRequest searchRequest ) throws LdapException
{
return connection.search( searchRequest );
}
代码示例来源:origin: com.qwazr/qwazr-library-ldap
@JsonIgnore
public Entry getEntry(final LdapConnection connection, final String filter, final String... attributes)
throws LdapException, CursorException, IOException {
connection.bind();
try (final EntryCursor cursor = connection.search(baseDn, filter, SearchScope.SUBTREE, attributes)) {
if (!cursor.next())
return null;
return cursor.get();
}
}
代码示例来源:origin: stackoverflow.com
void findEntry(LdapConnection connection, Entry entry, StringBuilder sb)
throws LdapException, CursorException {
sb.append(LdifUtils.convertToLdif(entry));
sb.append("\n");
EntryCursor cursor = connection.search(entry.getDn(), "(ObjectClass=*)", SearchScope.ONELEVEL, "*", "+");
while (cursor.next()) {
findEntry(connection, cursor.get(), sb);
}
}
代码示例来源:origin: apache/marmotta
/**
* Get child list
*
* @param entryDN The distinguished name of an Entry in the LDAP
* @param connection An initialized LDAP-Context
* @return All child's of an Entry
* @throws IOException
* @throws CursorException
* @throws LdapException
*/
private List<String> getChildList(String entryDN, LdapConnection connection) throws CursorException, IOException, LdapException {
List<String> childs = new ArrayList<String>();
EntryCursor cursor = connection.search("ou=system", "(objectclass=*)", SearchScope.ONELEVEL);
while (cursor.next()) {
Entry entry = cursor.get();
childs.add(entry.get("distinguishedName").getString());
}
//SearchResultDone done = cursor.getSearchResultDone();
//ResultCodeEnum resultCode = done.getLdapResult().getResultCode();
cursor.close();
// ResultCodeEnum.SUCCESS == resultCode
return childs;
}
代码示例来源:origin: org.apache.directory.api/api-ldap-client-api
/**
* {@inheritDoc}
*/
@Override
public <T> List<T> search( SearchRequest searchRequest,
EntryMapper<T> entryMapper )
{
List<T> entries = new ArrayList<>();
LdapConnection connection = null;
try
{
connection = connectionPool.getConnection();
for ( Entry entry : new EntryCursorImpl( connection.search( searchRequest ) ) )
{
entries.add( entryMapper.map( entry ) );
}
}
catch ( LdapException e )
{
throw new LdapRuntimeException( e );
}
finally
{
returnLdapConnection( connection );
}
return entries;
}
代码示例来源:origin: org.apache.directory.client.ldap/ldap-client-api
/**
* searches for an entry having the given DN
*
* @param dn the DN of the entry to be fetched
* @param attributes the attributes to be returned along with entry
* @return the Entry with the given DN or null if no entry exists with that DN
* @throws LdapException in case of any problems while searching for the DN
*/
public SearchResponse lookup( String dn, String... attributes ) throws LdapException
{
SearchResponse resp = null;
try
{
Cursor<SearchResponse> cursor = search( dn, "(objectClass=*)", SearchScope.OBJECT, attributes );
if( cursor.next() )
{
resp = cursor.get();
}
cursor.close();
}
catch( Exception e )
{
throw new LdapException( e );
}
return resp;
}
代码示例来源:origin: com.qwazr/qwazr-library-ldap
public List<Entry> search(final LdapConnection connection, final String filter, final int start, final int rows)
throws LdapException, CursorException, IOException {
connection.bind();
final SearchRequest request = new SearchRequestImpl();
request.setBase(new Dn(baseDn));
request.setFilter(filter);
request.setScope(SearchScope.SUBTREE);
request.setSizeLimit(start + rows);
try (final SearchCursor cursor = connection.search(request)) {
while (start > 0 && cursor.next())
;
final List<Entry> entries = new ArrayList<>();
while (rows > 0 && cursor.next())
entries.add(cursor.getEntry());
return entries;
}
}
代码示例来源:origin: org.openengsb.infrastructure/org.openengsb.infrastructure.ldap
/**
* Deletes the entire subtree of root but not root itself. Throws NoSuchNodeException if root does not exist. Throws
* MissingParentException if some node above root does not exist.
* */
public void deleteSubtreeExcludingRoot(Dn root) throws NoSuchNodeException, MissingParentException {
existsCheck(root);
try {
EntryCursor entryCursor = connection.search(root, "(objectclass=*)", SearchScope.ONELEVEL);
while (entryCursor.next()) {
deleteSubtreeIncludingRoot(entryCursor.get().getDn());
}
} catch (Exception e) {
throw new LdapDaoException(e);
}
}
代码示例来源:origin: com.qwazr/qwazr-library-ldap
public int count(final LdapConnection connection, final String filter, final int max)
throws LdapException, CursorException, IOException {
connection.bind();
final SearchRequest request = new SearchRequestImpl();
request.setBase(new Dn(baseDn));
request.setFilter(filter);
request.setScope(SearchScope.SUBTREE);
request.setSizeLimit(max);
try (final SearchCursor cursor = connection.search(request)) {
int count = 0;
while (cursor.next())
count++;
return count;
}
}
代码示例来源:origin: org.apache.directory.fortress/fortress-core
/**
* Perform normal ldap search accepting default batch size.
*
* @param connection is LdapConnection object used for all communication with host.
* @param baseDn contains address of distinguished name to begin ldap search
* @param scope indicates depth of search starting at basedn. 0 (base dn),
* 1 (one level down) or 2 (infinite) are valid values.
* @param filter contains the search criteria
* @param attrs is the requested list of attritubutes to return from directory search.
* @param attrsOnly if true pull back attribute names only.
* @return result set containing ldap entries returned from directory.
* @throws LdapException thrown in the event of error in ldap client or server code.
*/
protected SearchCursor search( LdapConnection connection, String baseDn, SearchScope scope, String filter,
String[] attrs, boolean attrsOnly ) throws LdapException
{
COUNTERS.incrementSearch();
SearchRequest searchRequest = new SearchRequestImpl();
searchRequest.setBase( new Dn( baseDn ) );
searchRequest.setScope( scope );
searchRequest.setFilter( filter );
searchRequest.setTypesOnly( attrsOnly );
searchRequest.addAttributes( attrs );
return connection.search( searchRequest );
}
代码示例来源:origin: org.apache.directory.fortress/fortress-core
/**
* Perform normal ldap search specifying default batch size and max entries to return.
*
* @param connection is LdapConnection object used for all communication with host.
* @param baseDn contains address of distinguished name to begin ldap search
* @param scope indicates depth of search starting at basedn. 0 (base dn),
* 1 (one level down) or 2 (infinite) are valid values.
* @param filter contains the search criteria
* @param attrs is the requested list of attritubutes to return from directory search.
* @param attrsOnly if true pull back attribute names only.
* @param maxEntries specifies the maximum number of entries to return in this search query.
* @return result set containing ldap entries returned from directory.
* @throws LdapException thrown in the event of error in ldap client or server code.
*/
protected SearchCursor search( LdapConnection connection, String baseDn, SearchScope scope, String filter,
String[] attrs, boolean attrsOnly, int maxEntries ) throws LdapException
{
COUNTERS.incrementSearch();
SearchRequest searchRequest = new SearchRequestImpl();
searchRequest.setBase( new Dn( baseDn ) );
searchRequest.setFilter( filter );
searchRequest.setScope( scope );
searchRequest.setSizeLimit( maxEntries );
searchRequest.setTypesOnly( attrsOnly );
searchRequest.addAttributes( attrs );
return connection.search( searchRequest );
}
内容来源于网络,如有侵权,请联系作者删除!