当前位置: 首页>>代码示例>>Java>>正文


Java LdapNetworkConnection类代码示例

本文整理汇总了Java中org.apache.directory.ldap.client.api.LdapNetworkConnection的典型用法代码示例。如果您正苦于以下问题:Java LdapNetworkConnection类的具体用法?Java LdapNetworkConnection怎么用?Java LdapNetworkConnection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LdapNetworkConnection类属于org.apache.directory.ldap.client.api包,在下文中一共展示了LdapNetworkConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: useBundleClasses

import org.apache.directory.ldap.client.api.LdapNetworkConnection; //导入依赖的package包/类
@Override
protected void useBundleClasses() throws Exception
{
    new LdapNetworkConnection().close();
    new SaslGssApiRequest();
    new Krb5LoginConfiguration();
    new AddFuture( new LdapNetworkConnection(), 2 );
    new LdapConnectionTemplate( new LdapConnectionPool( new DefaultPoolableLdapConnectionFactory(
        new LdapConnectionConfig() ) ) );
    FilterBuilder.and( FilterBuilder.not( FilterBuilder.contains( "cn", "a", "b" ) ) ).toString();

    // Test for DIRAPI-239
    PoolableObjectFactory<LdapConnection> factory = new DefaultPoolableLdapConnectionFactory(
        new LdapConnectionConfig() );
    Config config = new Config();
    LdapConnectionPool ldapConnectionPool = new LdapConnectionPool( factory, config );
    ldapConnectionPool.getLdapApiService();
    ldapConnectionPool.getTestOnBorrow();
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:20,代码来源:ApiLdapClientApiOsgiTest.java

示例2: addLdapGroup

import org.apache.directory.ldap.client.api.LdapNetworkConnection; //导入依赖的package包/类
protected Entry addLdapGroup(String cn, String description, String... memberDns) throws LdapException, IOException, CursorException {
	LdapNetworkConnection connection = ldapConnect();
	Entry entry = createGroupEntry(cn, description, memberDns);
	LOGGER.trace("Adding LDAP entry:\n{}", entry);
	connection.add(entry);
	display("Added LDAP group:"+entry);
	ldapDisconnect(connection);
	return entry;
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:10,代码来源:AbstractLdapTest.java

示例3: rangeSearch

import org.apache.directory.ldap.client.api.LdapNetworkConnection; //导入依赖的package包/类
private Attribute rangeSearch(LdapNetworkConnection connection, Entry previousEntry, String attrName, int high) {
	Dn dn = previousEntry.getDn();
	String attributesToGet = attrName + ";range=" + (high + 1) + "-*";
	Entry entry = null;
	OperationLog.logOperationReq(connection, "Search REQ base={0}, filter={1}, scope={2}, attributes={3}", 
			dn, AbstractLdapConfiguration.SEARCH_FILTER_ALL, SearchScope.OBJECT, attributesToGet);
	try {
		entry = connection.lookup( dn, attributesToGet );
		
		if ( entry==null ) {
            OperationLog.logOperationErr(connection, "Entry not found for {0}", dn);
            throw LdapUtil.processLdapException( "Range search for "+dn+" with "+attributesToGet+" failed", 
                new LdapNoSuchObjectException("No entry found for " + dn));
		}
	} catch (LdapException e) {
		OperationLog.logOperationErr(connection, "Search ERR {0}: {1}", e.getClass().getName(), e.getMessage(), e);
		throw LdapUtil.processLdapException("Range search for "+dn+" with "+attributesToGet+" failed", e);
	}
	
	OperationLog.logOperationRes(connection, "Search RES {0}", entry);
	
	return entry.get(attrName);
}
 
开发者ID:Evolveum,项目名称:connector-ldap,代码行数:24,代码来源:AdAttributeHandler.java

示例4: fetchEntry

import org.apache.directory.ldap.client.api.LdapNetworkConnection; //导入依赖的package包/类
/**
 * Fetch a single entry using its DN.
 * 
 * @param connection The LDAP connection to use
 * @param dn The entry's DN
 * @param ldapObjectClass The entry's ObjectClass
 * @param options The options to use 
 * @param schemaTranslator The Schema translator instance
 * @return The found entry, or null if none is found.
 */
public static Entry fetchEntry(LdapNetworkConnection connection, String dn, 
		org.apache.directory.api.ldap.model.schema.ObjectClass ldapObjectClass, 
		OperationOptions options, AbstractSchemaTranslator schemaTranslator) {
	String[] attributesToGet = getAttributesToGet(ldapObjectClass, options, schemaTranslator);
	Entry entry = null;
	LOG.ok("Search REQ base={0}, filter={1}, scope={2}, attributes={3}", 
			dn, AbstractLdapConfiguration.SEARCH_FILTER_ALL, SearchScope.OBJECT, attributesToGet);
	
	try {
	    entry = connection.lookup( dn, attributesToGet );
	} catch (LdapException e) {
		LOG.error("Search ERR {0}: {1}", e.getClass().getName(), e.getMessage(), e);
		throw processLdapException("Search for "+dn+" failed", e);
	}
	
	LOG.ok("Search RES {0}", entry);
	
	return entry;
}
 
开发者ID:Evolveum,项目名称:connector-ldap,代码行数:30,代码来源:LdapUtil.java

示例5: formatConnectionInfo

import org.apache.directory.ldap.client.api.LdapNetworkConnection; //导入依赖的package包/类
public static String formatConnectionInfo(LdapNetworkConnection connection) {
	StringBuilder sb = new StringBuilder();
	LdapConnectionConfig config = connection.getConfig();
	Integer port = null;
	if (config.isUseSsl()) {
		sb.append("ldaps://");
		if (config.getLdapPort() != 636) {
			port = config.getLdapPort();
		}
	} else {
		sb.append("ldap://");
		if (config.getLdapPort() != 389) {
			port = config.getLdapPort();
		}
	}
	sb.append(config.getLdapHost());
	if (port != null) {
		sb.append(":").append(port);
	}
	sb.append("/ ");
	return sb.toString();
}
 
开发者ID:Evolveum,项目名称:connector-ldap,代码行数:23,代码来源:LdapUtil.java

示例6: ldapRenameAttempt

import org.apache.directory.ldap.client.api.LdapNetworkConnection; //导入依赖的package包/类
private void ldapRenameAttempt(Dn oldDn, Dn newDn) {
	if (oldDn.equals(newDn)) {
		// nothing to rename, just ignore
	} else {
		LdapNetworkConnection connection = connectionManager.getConnection(oldDn);
		try {
			OperationLog.logOperationReq(connection, "MoveAndRename REQ {0} -> {1}", oldDn, newDn);
			// Make sure that DNs are passed in as (user-provided) strings. Otherwise the Directory API
			// will convert it do OID=value notation. And some LDAP servers (such as OpenDJ) does not handle
			// that well.
			connection.moveAndRename(oldDn.getName(), newDn.getName());
			OperationLog.logOperationRes(connection, "MoveAndRename RES OK {0} -> {1}", oldDn, newDn);
		} catch (LdapException e) {
			OperationLog.logOperationErr(connection, "MoveAndRename ERROR {0} -> {1}: {2}", oldDn, newDn, e.getMessage(), e);
			throw processLdapException("Rename/move of LDAP entry from "+oldDn+" to "+newDn+" failed", e);
		}
	}
}
 
开发者ID:Evolveum,项目名称:connector-ldap,代码行数:19,代码来源:AbstractLdapConnector.java

示例7: LdapWorker

import org.apache.directory.ldap.client.api.LdapNetworkConnection; //导入依赖的package包/类
public LdapWorker(Long domainId) throws Exception {
	this.domainId = domainId;
	ldapCfg = ldapConfigDao.get(domainId);
	try (InputStream is = new FileInputStream(new File(OmFileHelper.getConfDir(), ldapCfg.getConfigFileName()));
			Reader r = new InputStreamReader(is, UTF_8))
	{
		config.load(r);
		if (config.isEmpty()) {
			throw new RuntimeException("Error on LdapLogin : Configurationdata couldnt be retrieved!");
		}
		options = new LdapOptions(config);
	} catch (Exception e) {
		log.error("Error on LdapLogin : Configurationdata couldn't be retrieved!");
		throw e;
	}

	conn = new LdapNetworkConnection(options.host, options.port, options.secure);
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:19,代码来源:LdapLoginManagement.java

示例8: setup

import org.apache.directory.ldap.client.api.LdapNetworkConnection; //导入依赖的package包/类
@Before
  public void setup() throws Exception {
  	LdapConnectionConfig config = new LdapConnectionConfig();
      config.setLdapHost( "localhost" );
      config.setLdapPort( ldapServer.getPort() );
      config.setName(ADMIN_DN);
      config.setCredentials(ADMIN_PASSWORD);
  	connection = new LdapNetworkConnection( config);
  	connection.bind(ADMIN_DN, ADMIN_PASSWORD);
connection.add(
  	        new DefaultEntry(
  	        	USER_DN,
  	            "ObjectClass: top",
  	            "ObjectClass: person",
  	            "userPassword", USER_PASSWORD,
  	            "cn", "testUser",
  	            "sn", "test"
  	            ) );
connection.unBind();
  }
 
开发者ID:cloudstore,项目名称:cloudstore,代码行数:21,代码来源:SimpleLdapClientTest.java

示例9: test822ModifyAccountHt

import org.apache.directory.ldap.client.api.LdapNetworkConnection; //导入依赖的package包/类
@Test
   public void test822ModifyAccountHt() throws Exception {
	final String TEST_NAME = "test822ModifyAccountHt";
       TestUtil.displayTestTile(this, TEST_NAME);

       // GIVEN
       Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
       OperationResult result = task.getResult();
       
       long tsStart = System.currentTimeMillis();
       
       // WHEN
       TestUtil.displayWhen(TEST_NAME);
       LdapNetworkConnection connection = ldapConnect();
       Modification modCn = new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, "sn", ACCOUNT_HT_SN_MODIFIED);
       connection.modify(toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN), modCn);
	ldapDisconnect(connection);

	waitForTaskNextRunAssertSuccess(getSyncTaskOid(), true);
       
       // THEN
       TestUtil.displayThen(TEST_NAME);
       result.computeStatus();
       TestUtil.assertSuccess(result);
       
       long tsEnd = System.currentTimeMillis();
       
       PrismObject<UserType> user = findUserByUsername(ACCOUNT_HT_UID);
       assertNotNull("No user "+ACCOUNT_HT_UID+" created", user);
       assertUser(user, user.getOid(), ACCOUNT_HT_UID, ACCOUNT_HT_CN, ACCOUNT_HT_GIVENNAME, ACCOUNT_HT_SN_MODIFIED);

       assertStepSyncToken(getSyncTaskOid(), 7, tsStart, tsEnd);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:34,代码来源:AbstractLdapSynchronizationTest.java

示例10: assertNoLdapAccount

import org.apache.directory.ldap.client.api.LdapNetworkConnection; //导入依赖的package包/类
protected void assertNoLdapAccount(UserLdapConnectionConfig config, String uid, String cn) throws LdapException, IOException, CursorException {
	LdapNetworkConnection connection = ldapConnect(config);
	List<Entry> entriesCn = ldapSearch(config, connection, "(cn="+cn+")");
	List<Entry> entriesSamAccountName = ldapSearch(config, connection, "(sAMAccountName="+uid+")");
	ldapDisconnect(connection);

	assertEquals("Unexpected number of entries for cn="+cn+": "+entriesCn, 0, entriesCn.size());
	assertEquals("Unexpected number of entries for sAMAccountName="+uid+": "+entriesSamAccountName, 0, entriesSamAccountName.size());
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:10,代码来源:AbstractAdLdapMultidomainTest.java

示例11: test702LockOutBarbossa

import org.apache.directory.ldap.client.api.LdapNetworkConnection; //导入依赖的package包/类
@Test
   public void test702LockOutBarbossa() throws Exception {
	final String TEST_NAME = "test702LockOutBarbossa";
       TestUtil.displayTestTile(this, TEST_NAME);
       
       Entry entry = getLdapAccountByUid(USER_BARBOSSA_USERNAME);
       display("LDAP Entry before", entry);

       // WHEN
       TestUtil.displayWhen(TEST_NAME);
       for (int i = 0; i < 10; i++) {
       	LdapNetworkConnection conn;
       	try {
       		conn = ldapConnect(null, entry.getDn().toString(), "this password is wrong");
       	} catch (SecurityException e) {
       		// Good bad attempt
       		continue;
       	}
       	assertNotReached();
       }
       
       // THEN
       TestUtil.displayThen(TEST_NAME);
       
       entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME);
       display("LDAP Entry after", entry);
       
       PrismObject<ShadowType> shadow = getShadowModel(accountBarbossaOid);
       display("Shadow (model)", shadow);
       ActivationType activation = shadow.asObjectable().getActivation();
       assertNotNull("No activation", activation);
       LockoutStatusType lockoutStatus = shadow.asObjectable().getActivation().getLockoutStatus();
       assertEquals("Wrong lockout status", LockoutStatusType.LOCKED, lockoutStatus);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:35,代码来源:TestOpenLdap.java

示例12: makeBadLoginAttempt

import org.apache.directory.ldap.client.api.LdapNetworkConnection; //导入依赖的package包/类
private void makeBadLoginAttempt(String uid) throws LdapException, IOException {
	try {
		LdapNetworkConnection conn = ldapConnect(toAccountDn(uid), "thisIsAwRoNgPASSW0RD");
		if (conn.isAuthenticated()) {
			AssertJUnit.fail("Bad authentication went good for "+uid);
		}
	} catch (SecurityException e) {
		// this is expected
	}
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:11,代码来源:AbstractEDirTest.java

示例13: doAdditionalRenameModifications

import org.apache.directory.ldap.client.api.LdapNetworkConnection; //导入依赖的package包/类
@Override
protected void doAdditionalRenameModifications(LdapNetworkConnection connection) throws LdapException {
	Modification mod = new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, 
			ATTRIBUTE_SAM_ACCOUNT_NAME_NAME, ACCOUNT_HTM_UID);
	connection.modify(toAccountDn(ACCOUNT_HTM_UID, ACCOUNT_HTM_CN), mod);
	display("Modified "+toAccountDn(ACCOUNT_HT_UID, ACCOUNT_HT_CN)+" " + ATTRIBUTE_SAM_ACCOUNT_NAME_NAME + 
			" -> "+ACCOUNT_HTM_UID+": "+mod);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:9,代码来源:AbstractAdLdapTest.java

示例14: assertNoLdapAccount

import org.apache.directory.ldap.client.api.LdapNetworkConnection; //导入依赖的package包/类
protected void assertNoLdapAccount(String uid, String cn) throws LdapException, IOException, CursorException {
	LdapNetworkConnection connection = ldapConnect();
	List<Entry> entriesCn = ldapSearch(connection, "(cn="+cn+")");
	List<Entry> entriesSamAccountName = ldapSearch(connection, "(sAMAccountName="+uid+")");
	ldapDisconnect(connection);

	assertEquals("Unexpected number of entries for cn="+cn+": "+entriesCn, 0, entriesCn.size());
	assertEquals("Unexpected number of entries for sAMAccountName="+uid+": "+entriesSamAccountName, 0, entriesSamAccountName.size());
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:10,代码来源:AbstractAdLdapTest.java

示例15: searchLdapAccount

import org.apache.directory.ldap.client.api.LdapNetworkConnection; //导入依赖的package包/类
protected Entry searchLdapAccount(UserLdapConnectionConfig config, String filter) throws LdapException, IOException, CursorException {
	LdapNetworkConnection connection = ldapConnect(config);
	List<Entry> entries = ldapSearch(config, connection, filter);
	ldapDisconnect(connection);

	assertEquals("Unexpected number of entries for "+filter+": "+entries, 1, entries.size());
	Entry entry = entries.get(0);

	return entry;
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:11,代码来源:AbstractLdapTest.java


注:本文中的org.apache.directory.ldap.client.api.LdapNetworkConnection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。