com.unboundid.ldap.sdk.LDAPConnection.getEntry()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(185)

本文整理了Java中com.unboundid.ldap.sdk.LDAPConnection.getEntry()方法的一些代码示例,展示了LDAPConnection.getEntry()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LDAPConnection.getEntry()方法的具体详情如下:
包路径:com.unboundid.ldap.sdk.LDAPConnection
类名称:LDAPConnection
方法名:getEntry

LDAPConnection.getEntry介绍

[英]Retrieves the entry with the specified DN. All user attributes will be requested in the entry to return.
[中]检索具有指定DN的项。将在条目中请求所有用户属性以返回。

代码示例

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition

/**
 * Retrieves the entry with the specified DN.  All user attributes will be
 * requested in the entry to return.
 *
 * @param  dn  The DN of the entry to retrieve.  It must not be {@code null}.
 *
 * @return  The requested entry, or {@code null} if the target entry does not
 *          exist or no entry was returned (e.g., if the authenticated user
 *          does not have permission to read the target entry).
 *
 * @throws  LDAPException  If a problem occurs while sending the request or
 *                         reading the response.
 */
public SearchResultEntry getEntry(final String dn)
    throws LDAPException
{
 return getEntry(dn, (String[]) null);
}

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition

/**
 * Retrieves the entry with the specified DN.  All user attributes will be
 * requested in the entry to return.
 *
 * @param  dn  The DN of the entry to retrieve.  It must not be {@code null}.
 *
 * @return  The requested entry, or {@code null} if the target entry does not
 *          exist or no entry was returned (e.g., if the authenticated user
 *          does not have permission to read the target entry).
 *
 * @throws  LDAPException  If a problem occurs while sending the request or
 *                         reading the response.
 */
public SearchResultEntry getEntry(final String dn)
    throws LDAPException
{
 return getEntry(dn, (String[]) null);
}

代码示例来源:origin: com.btmatthews.ldapunit/ldapunit

/**
 * Verify that an entry identified by {@code dn} exists.
 *
 * @param dn The distinguished name.
 * @return {@code true} if an entry identified by {@code dn} exists. Otherwise, {@code false} is returned.
 */
public boolean verifyDNExists(final String dn) {
  try {
    final SearchResultEntry entry = connection.getEntry(dn);
    return entry != null;
  } catch (final LDAPException e) {
    throw new DirectoryTesterException("Error communicating with LDAP directory server", e);
  }
}

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition

if (entryDN == null)
 e = connection.getEntry("", SUBSCHEMA_SUBENTRY_REQUEST_ATTRS);
 e = connection.getEntry(entryDN, SUBSCHEMA_SUBENTRY_REQUEST_ATTRS);

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition

if (entryDN == null)
 e = connection.getEntry("", SUBSCHEMA_SUBENTRY_REQUEST_ATTRS);
 e = connection.getEntry(entryDN, SUBSCHEMA_SUBENTRY_REQUEST_ATTRS);

代码示例来源:origin: com.btmatthews.ldapunit/ldapunit

/**
 * Verify that the entry identified by {@code dn} has an attribute named {@code attributeName}.
 *
 * @param dn            The distinguished name.
 * @param attributeName The attribute name.
 * @return {@code true} if an entry identified by {@code dn} exists and has an attributed named
 *         {@code attributeName}. Otherwise, {@code false} is returned.
 */
public boolean verifyDNHasAttribute(final String dn,
                  final String attributeName) {
  try {
    final SearchResultEntry entry = connection.getEntry(dn, attributeName);
    return entry != null && entry.hasAttribute(attributeName);
  } catch (final LDAPException e) {
    throw new DirectoryTesterException("Error communicating with LDAP directory server", e);
  }
}

代码示例来源:origin: com.btmatthews.ldapunit/ldapunit

/**
 * Verify that the entry identified by {@code dn} has an attribute named {@code attributeName} with
 * the attribute value(s) {@code attributeName}.
 *
 * @param dn             The distinguished name.
 * @param attributeName  The attribute name.
 * @param attributeValue The attribute value(s).
 * @return {@code true} if an antry identified by {@code dn} exists with an an attribute named {@code attributeName}
 *         that has value(s) {@code attributeValue}. Otherwise, {@code false} is returned.
 */
public boolean verifyDNHasAttributeValue(final String dn,
                     final String attributeName,
                     final String... attributeValue) {
  try {
    final SearchResultEntry entry = connection.getEntry(dn, attributeName);
    if (entry != null && entry.hasAttribute(attributeName)) {
      final Set<String> expectedValues = new HashSet<String>(Arrays.asList(attributeValue));
      final Set<String> actualValues = new HashSet<String>(Arrays.asList(entry.getAttributeValues(attributeName)));
      if (actualValues.containsAll(expectedValues)) {
        actualValues.removeAll(expectedValues);
        if (actualValues.size() == 0) {
          return true;
        }
      }
    }
  } catch (final LDAPException e) {
    throw new DirectoryTesterException("Error communicating with LDAP directory server", e);
  }
  return false;
}

代码示例来源:origin: hlavki/g-suite-identity-sync

@Override
public void removeGroup(String groupName) throws LdapSystemException {
  try (LDAPConnection conn = ldapPool.getConnection()) {
    String groupDN = getGroupDN(groupName);
    SearchResultEntry entry = conn.getEntry(groupDN, GROUP_NAME_ATTR);
    if (entry != null) {
      conn.delete(groupDN);
    }
  } catch (LDAPException e) {
    throw new LdapSystemException(e);
  }
}

代码示例来源:origin: com.btmatthews.ldapunit/ldapunit

/**
 * Verify that the entry identified by {@code dn} is of type {@code objectclass}.
 *
 * @param dn          The distinguished name.
 * @param objectclass The type name.
 * @return {@code true} if an entry identified by {@code dn} exists and has attribute named {@code objectclass}.
 *         Otherwise, {@code false} is returned.
 */
public boolean verifyDNIsA(final String dn,
              final String objectclass) {
  try {
    final SearchResultEntry entry = connection.getEntry(dn, "objectclass");
    return entry != null
        && entry.hasAttribute("objectclass")
        && arrayContains(entry.getAttributeValues("objectclass"), objectclass);
  } catch (final LDAPException e) {
    throw new DirectoryTesterException("Error communicating with LDAP directory server", e);
  }
}

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition

final SearchResultEntry entry = conn.getEntry(dn, attributes);
releaseConnection(conn);
return entry;
 final SearchResultEntry entry = newConn.getEntry(dn, attributes);
 releaseConnection(newConn);
 return entry;

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition

final SearchResultEntry entry = conn.getEntry(dn, attributes);
releaseConnection(conn);
return entry;
 final SearchResultEntry entry = newConn.getEntry(dn, attributes);
 releaseConnection(newConn);
 return entry;

代码示例来源:origin: hlavki/g-suite-identity-sync

private void creatOrgUnits(LDAPConnection conn) throws LDAPException {
  String peopleDn = config.getLdapUserBaseDN();
  if (conn.getEntry(peopleDn) == null) {
    Entry entry = new Entry(peopleDn);
    entry.addAttribute("objectClass", "top");
    entry.addAttribute("objectClass", "organizationalUnit");
    conn.add(entry);
  }
  String groupDn = config.getLdapGroupsBaseDN();
  if (conn.getEntry(groupDn) == null) {
    Entry entry = new Entry(groupDn);
    entry.addAttribute("objectClass", "top");
    entry.addAttribute("objectClass", "organizationalUnit");
    conn.add(entry);
  }
}

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition

final Entry taskEntry = connection.getEntry(getTaskDN(taskID));
if (taskEntry == null)

代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition

/**
 * Schedules a new instance of the provided task in the Directory Server.
 *
 * @param  task        The task to be scheduled.
 * @param  connection  The connection to the Directory Server in which the
 *                     task is to be scheduled.
 *
 * @return  A {@code Task} object representing the task that was scheduled and
 *          re-read from the server.
 *
 * @throws  LDAPException  If a problem occurs while communicating with the
 *                         Directory Server, or if it rejects the task.
 *
 * @throws  TaskException  If the entry read back from the server after the
 *                         task was created could not be parsed as a task.
 */
public static Task scheduleTask(final Task task,
                final LDAPConnection connection)
    throws LDAPException, TaskException
{
 final Entry taskEntry = task.createTaskEntry();
 connection.add(task.createTaskEntry());
 final Entry newTaskEntry = connection.getEntry(taskEntry.getDN());
 if (newTaskEntry == null)
 {
  // This should never happen.
  throw new LDAPException(ResultCode.NO_SUCH_OBJECT);
 }
 return Task.decodeTask(newTaskEntry);
}

相关文章

LDAPConnection类方法