com.novell.ldap.LDAPConnection.<init>()方法的使用及代码示例

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

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

LDAPConnection.<init>介绍

[英]Constructs a new LDAPConnection object, which represents a connection to an LDAP server.

Calling the constructor does not actually establish the connection. To connect to the LDAP server, use the connect method.
[中]构造一个新的LDAPConnection对象,该对象表示到LDAP服务器的连接。
调用构造函数实际上并不建立连接。要连接到LDAP服务器,请使用connect方法。

代码示例

代码示例来源:origin: stackoverflow.com

public static LDAPConnection getConnection() throws LDAPException {
  // host, port, username and password
  return new LDAPConnection("com.example.local", 389, "Administrator@com.example.local", "admin");
}

代码示例来源:origin: glyptodon/guacamole-client

return new LDAPConnection();
return new LDAPConnection(new LDAPJSSESecureSocketFactory());
return new LDAPConnection(new LDAPJSSEStartTLSFactory());

代码示例来源:origin: neo4j-contrib/neo4j-apoc-procedures

private LDAPConnection getConnection() throws LDAPException, UnsupportedEncodingException {
//        LDAPSocketFactory ssf;
//        Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
      // String path ="C:\\j2sdk1.4.2_09\\jre\\lib\\security\\cacerts";
      //op("the trustStore: " + System.getProperty("javax.net.ssl.trustStore"));
      // System.setProperty("javax.net.ssl.trustStore", path);
//        op(" reading the strustStore: " + System.getProperty("javax.net.ssl.trustStore"));
//        ssf = new LDAPJSSESecureSocketFactory();
//        LDAPConnection.setSocketFactory(ssf);

      LDAPConnection lc = new LDAPConnection();
      lc.connect(ldapHost, ldapPort);

      // bind to the server
      lc.bind(ldapVersion, loginDN, password.getBytes("UTF8"));
      // tbd
      // LDAPConnection pooling here?
      //
      return lc;
    }

代码示例来源:origin: com.novell.ldap/jldap

/**
 * Constructs a new LDAPConnection object, which represents a connection
 * to an LDAP server.
 *
 * @see <a href="../../../../api/com/novell/ldap/LDAPConnection.html#LDAPConnection()">
    com.novell.ldap.LDAPConnection.LDAPConnection()</a>
 */
public LDAPConnection()
{
  conn = new com.novell.ldap.LDAPConnection();
  return;
}

代码示例来源:origin: stackoverflow.com

LDAPConnection ldap = new LDAPConnection("ldap.example.com", 389);

代码示例来源:origin: stackoverflow.com

int maxAttempts = 3;
for(int attempts = 0; attempts < maxAttempts; attempts++) {
  try {
     connect = new LDAPConnection(...);
     /*if connection can be established then break from loop, but keep connection alive*/
     break;
  } catch(LDAPException exc) {
     if(attempt == (maxAttempts-1)) {
       //throw exception message
       throw exc;
     }
  }
  Thread.sleep(1000);
}

代码示例来源:origin: com.novell.ldap/jldap

/**
 * Constructs a new LDAPConnection object, which will use the supplied
 * class factory to construct a socket connection during
 * LDAPConnection.connect method.
 *
 * @see <a href="../../../../api/com/novell/ldap/LDAPConnection.html#LDAPConnection(com.novell.ldap.LDAPSocketFactory)">
    com.novell.ldap.LDAPConnection.LDAPConnection(LDAPSocketFactory)</a>
 */
public LDAPConnection(LDAPSocketFactory factory)
{
  if( (factory != null) &&
      (factory instanceof com.novell.ldap.LDAPSocketFactory)) {
    conn = new com.novell.ldap.LDAPConnection(
                (com.novell.ldap.LDAPSocketFactory)factory);
  } else {
    conn = new com.novell.ldap.LDAPConnection( getSocketImpl(factory));
  }
  return;
}

代码示例来源:origin: stackoverflow.com

LDAPConnection myCon = new LDAPConnection("192.168.1.1",389);
myCon.delete("cn=Alan,ou=engineers,dc=fool,dc=com");

代码示例来源:origin: sakaiproject/sakai

/**
 * Return a new LDAPConnection with the appropriate socket factory set for the connection type.
 */
private LDAPConnection createConnectionWithSocketFactory() {
  LDAPSocketFactory factory;
  if (config.isSecureConnection()) {
    factory = config.getSecureSocketFactory();
    if (factory == null) {
      throw new RuntimeException("You must set a 'secureSocketFactory' (in jldap-beans.xml) when using LDAPS");
    }
  } else {
    factory = config.getSocketFactory();
  }
  if (factory == null) {
    return new LDAPConnection();
  } else {
    return new LDAPConnection(factory);
  }
}

代码示例来源:origin: stackoverflow.com

LDAPConnection ldc = new LDAPConnection()
ldc.connect(...);
if (ldc.isConnected())
{
  do good stuff
}
else
{
  getLDAPConnection(...);
}

代码示例来源:origin: stackoverflow.com

SSLUtil su = new SSLUtil(new TrustAllTrustManager());
SSLSocketFactory sf = su.createSSLSocketFactory();
LDAPConnection connection = new LDAPConnection(sf,"localhost", 10636);

代码示例来源:origin: stackoverflow.com

LDAPConnection ld = new LDAPConnection();
ld.connect(LDAP_SERVER, LDAP_PORT);
LDAPSearchResults res = ld.search(BASE_DN, SEARCH_SCOPE, "(uid=" + THE_ID +")", null, false);

代码示例来源:origin: stackoverflow.com

final String hostname = "the hostname";
final int port = PORT; // sometimes 389
try
{
  final LDAPConnection connection = new LDAPConnection(hostname,port);
  try
  {
    final SimpleBindRequest request = new SimpleBindRequest(bindDN,bindPassword);
    final BindResult result = connection.bind(request);
  }
  finally
  {
    connection.close();
  }
}
catch(final LDAPException ex)
{
   handle the exception ...;
}

代码示例来源:origin: stackoverflow.com

try {
 // Connect to the server
 LDAPConnection ldapConnection = new LDAPConnection(...);
 try {
   for(String dn:listOfDns) {
     Entry entry = ldapConnection.getEntry(dn,"1.1");
   }
 } catch(LDAPException ex) {
   // handle an exception from the search
 } finally {
   ldapConnection.close();
 }
} catch(LDAPException ex) {
   // handle an exception from the connection attempt
}

代码示例来源:origin: stackoverflow.com

public static LDAPConnection getNewSSLConnection(String address, int port, BindRequest bindRequest) throws LDAPException, GeneralSecurityException
{
  SSLUtil sslUtil = new SSLUtil(new TrustAllTrustManager());
  SSLSocketFactory sslSocketFactory = sslUtil.createSSLSocketFactory();
  LDAPConnection ldc = new LDAPConnection(sslSocketFactory);
  ldc.connect(address, port);
  ldc.bind(bindRequest);
  return ldc;
}

代码示例来源:origin: stackoverflow.com

LDAPConnection myCon = new LDAPConnection("localhost",389);
LDAPModificationSet mods = new LDAPModificationSet();
mods.add(LDAPModification.DELETE, new LDAPAttribute("notifyTo"));
myCon.modify("uid=test1, ou=People, o=domain.com, o=isp", mods);

代码示例来源:origin: stackoverflow.com

LDAPConnection conn = new LDAPConnection();
conn.connect("blah.blah.address", 389);

String[] attrIDs = {"uniqueMember"};
LDAPSearchResults search = conn.search("dc=foo,dc=bar",
                    LDAPConnection.SCOPE_ONE,
                    "cn=testgroup", attrIDs, false);

while(search.hasMore()) {
  LDAPEntry entry = search.next();
  for (String string : entry.getAttribute("uniqueMember").getStringValueArray()) {
    System.out.println(string);
  }
}

代码示例来源:origin: stackoverflow.com

import com.unboundid.ldap.sdk.Filter;
import com.unboundid.ldap.sdk.LDAPConnection;
import com.unboundid.ldap.sdk.LDAPException;
import com.unboundid.ldap.sdk.SearchScope;
import com.unboundid.ldap.sdk.SearchResult;

public final class BSFilter {
 public static void main(String... args) {
  try {
   Filter searchFilter =
    Filter.create("cn=abc\"and'def");
   LDAPConnection connection =
    new LDAPConnection("localhost",1389);
   SearchResult searchResult =
    connection.search("dc=example,dc=com",SearchScope.ONE,
             searchFilter,"1.1");
   assert(searchResult.getSearchEntries().size() == 0);
  } catch(LDAPException lex) {
   lex.printStackTrace();
   return;
  }
 }
}

代码示例来源:origin: OpenNMS/opennms

/** {@inheritDoc} */
  @Override
  public void connect(final InetAddress address, final int port, final int timeout) throws IOException, Exception {
    super.connect(address, port, timeout);
    final LDAPConnection lc = new LDAPConnection(new TimeoutLDAPSocket(timeout));
    lc.connect(InetAddressUtils.str(address), port);
  }
}

代码示例来源:origin: org.opennms/opennms-detector-lineoriented

/** {@inheritDoc} */
  @Override
  public void connect(final InetAddress address, final int port, final int timeout) throws IOException, Exception {
    super.connect(address, port, timeout);
    final LDAPConnection lc = new LDAPConnection(new TimeoutLDAPSocket(timeout));
    lc.connect(InetAddressUtils.str(address), port);
  }
}

相关文章