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


Java DirContextAdapter.setAttributeValues方法代码示例

本文整理汇总了Java中org.springframework.ldap.core.DirContextAdapter.setAttributeValues方法的典型用法代码示例。如果您正苦于以下问题:Java DirContextAdapter.setAttributeValues方法的具体用法?Java DirContextAdapter.setAttributeValues怎么用?Java DirContextAdapter.setAttributeValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.ldap.core.DirContextAdapter的用法示例。


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

示例1: create

import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
@Override
public UserOrg create(final UserOrg entry) {
	// Build the DN
	final Name dn = buildDn(entry);

	// Create the LDAP entry
	entry.setDn(dn.toString());
	final DirContextAdapter context = new DirContextAdapter(dn);
	context.setAttributeValues(OBJECT_CLASS, new String[] { peopleClass });
	mapToContext(entry, context);
	template.bind(context);

	// Also, update the cache
	ldapCacheRepository.create(entry);

	// Return the original entry with updated DN
	return entry;
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:19,代码来源:UserLdapRepository.java

示例2: create

import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
public void create(OrgPerson person) {
	DistinguishedName dn = new DistinguishedName();
       dn.add("ou", person.getCountry());
       dn.add("ou", person.getCompany());
       dn.add("cn", person.getFullname());

       DirContextAdapter ctx = new DirContextAdapter();
       ctx.setAttributeValues("objectclass", new String[] { "top", "person" });
       ctx.setAttributeValue("cn", person.getFullname());
       ctx.setAttributeValue("sn", person.getLastname());
       ctx.setAttributeValue("description", person.getDescription());
       ldapTemplate.bind(dn, ctx, null);
	this.getHibernateTemplate().saveOrUpdate(person);


}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:17,代码来源:DummyDaoLdapAndHibernateImpl.java

示例3: testBindAndUnbind_Plain

import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
@Test
public void testBindAndUnbind_Plain() {
	DirContextAdapter adapter = new DirContextAdapter();
	adapter.setAttributeValues("objectclass", new String[] { "top", "person" });
	adapter.setAttributeValue("cn", "Some Person4");
	adapter.setAttributeValue("sn", "Person4");
	tested.bind("cn=Some Person4, ou=company1, ou=Sweden," + base, adapter, null);

	DirContextAdapter result = (DirContextAdapter) tested
			.lookup("cn=Some Person4, ou=company1, ou=Sweden," + base);

	assertThat(result.getStringAttribute("cn")).isEqualTo("Some Person4");
	assertThat(result.getStringAttribute("sn")).isEqualTo("Person4");
	assertThat(result.getDn()).isEqualTo(LdapUtils.newLdapName("cn=Some Person4,ou=company1,ou=Sweden," + base));

	tested.unbind("cn=Some Person4,ou=company1,ou=Sweden," + base);
	try {
		tested.lookup("cn=Some Person4, ou=company1, ou=Sweden," + base);
		fail("NameNotFoundException expected");
	}
	catch (NameNotFoundException expected) {
		assertThat(true).isTrue();
	}
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:25,代码来源:LdapTemplateNoBaseSuffixITest.java

示例4: testBindAndRebindWithDirContextAdapterOnly

import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
@Test
public void testBindAndRebindWithDirContextAdapterOnly() {
	DirContextAdapter adapter = new DirContextAdapter(LdapUtils.newLdapName(DN));
	adapter.setAttributeValues("objectclass", new String[] { "top",
			"person" });
	adapter.setAttributeValue("cn", "Some Person4");
	adapter.setAttributeValue("sn", "Person4");

	tested.bind(adapter);
	verifyBoundCorrectData();
	adapter.setAttributeValue("sn", "Person4.Changed");
	tested.rebind(adapter);
	verifyReboundCorrectData();
	tested.unbind(DN);
	verifyCleanup();
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:17,代码来源:LdapTemplateBindUnbindITest.java

示例5: create

import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
/**
 * Create a new group. There is no synchronized block, so error could occur; this is assumed for performance
 * purpose.
 * 
 * @param dn
 *            The DN of new customer. Must ends with the OU.
 * @param ou
 *            The formatted OU.
 */
public void create(final String dn, final String ou) {

	// First create the LDAP entry
	log.info("Customer (OU) {} will be created as {}", ou, dn);
	final DirContextAdapter context = new DirContextAdapter(dn);
	context.setAttributeValues("objectClass", new String[] { CUSTOMER_OF_PROJECT });
	mapToContext(ou, context);
	getUser().getTemplate().bind(context);
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:19,代码来源:ProjectCustomerLdapRepository.java

示例6: create

import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
@Override
public T create(final String dn, final String cn) {
	final T container = newContainer(dn, cn);

	// First create the LDAP entry
	log.info("{} {} will be created as {}", type.name(), container.getName(), dn);
	final DirContextAdapter context = new DirContextAdapter(dn);
	context.setAttributeValues("objectClass", new String[] { className });
	mapToContext(container, context);
	template.bind(context);

	// Return the new container
	return container;
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:15,代码来源:AbstractContainerLdaRepository.java

示例7: mapToContext

import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
/**
 * The WriteableLdapUserServiceImpl implementation is overwritted because 
 * it doest not allow to remove attribute.
 * @param ldapUser
 * @param context
 */
protected void mapToContext(final LdapUser ldapUser, final DirContextAdapter context) {
	List<String> attributesNames = ldapUser.getAttributeNames();
	for (String ldapAttributeName : attributesNames) {
		List<String> listAttr = new ArrayList<>();
		listAttr = ldapUser.getAttributes(ldapAttributeName);
		// The attribute exists
		if (listAttr != null && listAttr.size() != 0) {
			context.setAttributeValues(ldapAttributeName, listAttr.toArray());
		} else {
			// manage the attributes erasing
			context.setAttributeValues(ldapAttributeName, null);
		}
	}
}
 
开发者ID:EsupPortail,项目名称:esup-smsu,代码行数:21,代码来源:WriteableLdapUserServiceSMSUImpl.java

示例8: mapUserToContext

import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
private void mapUserToContext(DirContextAdapter context, User user) {
    context.setAttributeValues("objectclass", new String[] { "inetOrgPerson", "posixAccount", "top" });
    context.setAttributeValue("givenName", user.getAttributes().get("givenName"));
    context.setAttributeValue("sn", user.getAttributes().get("sn"));
    context.setAttributeValue("uid", user.getAttributes().get("uid"));
    context.setAttributeValue("uidNumber", user.getAttributes().get("uidNumber"));
    context.setAttributeValue("gidNumber", user.getAttributes().get("gidNumber"));
    context.setAttributeValue("cn", user.getAttributes().get("userName"));
    context.setAttributeValue("mail", user.getAttributes().get("mail"));
    context.setAttributeValue("homeDirectory", user.getAttributes().get("homeDirectory"));

    context.setAttributeValue("gecos", user.getAttributes().get("resetKey"));
    context.setAttributeValue("userPassword", user.getAttributes().get("userPassword"));

    String description = "";
    if (user.getAttributes().get("tenant") != null) {
        description += "tenant=" + user.getAttributes().get("tenant");
    }
    if (user.getAttributes().get("edOrg") != null) {
        description += ",edOrg=" + user.getAttributes().get("edOrg");
    }
    if (!"".equals(description)) {
        context.setAttributeValue("description", "tenant=" + user.getAttributes().get("tenant") + "," + "edOrg="
                + user.getAttributes().get("edOrg"));
    }

    if (user.getAttributes().containsKey("employeeNumber")) {
        context.setAttributeValue("employeeNumber", user.getAttributes().get("employeeNumber"));
    }
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:31,代码来源:UserService.java

示例9: create

import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
public void create(String country, String company, String fullname,
        String lastname, String description) {
    DistinguishedName dn = new DistinguishedName();
    dn.add("ou", country);
    dn.add("ou", company);
    dn.add("cn", fullname);

    DirContextAdapter ctx = new DirContextAdapter();
    ctx.setAttributeValues("objectclass", new String[] { "top", "person" });
    ctx.setAttributeValue("cn", fullname);
    ctx.setAttributeValue("sn", lastname);
    ctx.setAttributeValue("description", description);
    ldapTemplate.bind(dn, ctx, null);
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:15,代码来源:LdapDummyDaoImpl.java

示例10: createRecursivelyAndUnbindSubnode

import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
@Override
public void createRecursivelyAndUnbindSubnode() {
    DirContextAdapter ctx = new DirContextAdapter();
    ctx.setAttributeValues("objectclass", new String[]{"top", "organizationalUnit"});
    ctx.setAttributeValue("ou", "dummy");
    ctx.setAttributeValue("description", "dummy description");

    ldapTemplate.bind("ou=dummy", ctx, null);
    ldapTemplate.bind("ou=dummy,ou=dummy", ctx, null);
    ldapTemplate.unbind("ou=dummy,ou=dummy");
    ldapTemplate.unbind("ou=dummy");
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:13,代码来源:LdapDummyDaoImpl.java

示例11: create

import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
public void create(String country, String company, String fullname, String lastname, String description) {
	DistinguishedName dn = new DistinguishedName();
	dn.add("ou", country);
	dn.add("ou", company);
	dn.add("cn", fullname);

	DirContextAdapter ctx = new DirContextAdapter();
	ctx.setAttributeValues("objectclass", new String[] { "top", "person" });
	ctx.setAttributeValue("cn", fullname);
	ctx.setAttributeValue("sn", lastname);
	ctx.setAttributeValue("description", description);
	ldapTemplate.bind(dn, ctx, null);
	jdbcTemplate.update("insert into PERSON values(?, ?, ?)", new Object[] { fullname, lastname, description });
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:15,代码来源:LdapAndJdbcDummyDaoImpl.java

示例12: prepareTestedInstance

import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
@Before
public void prepareTestedInstance() throws Exception {
	DirContextAdapter adapter = new DirContextAdapter();
	adapter.setAttributeValues("objectclass", new String[] { "top", "person" });
	adapter.setAttributeValue("cn", "Some Person6");
	adapter.setAttributeValue("sn", "Person6");
	adapter.setAttributeValue("description", "Some description");

	tested.bind(DN, adapter, null);
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:11,代码来源:LdapTemplateRenameITest.java

示例13: prepareTestedInstance

import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
@Before
public void prepareTestedInstance() throws Exception {
	DirContextAdapter adapter = new DirContextAdapter();
	adapter.setAttributeValues("objectclass", new String[] { "top", "person" });
	adapter.setAttributeValue("cn", "Some\\Person6");
	adapter.setAttributeValue("sn", "Person6");
	adapter.setAttributeValue("description", "Some description");

	tested.unbind(DN);
	tested.bind(DN, adapter, null);
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:12,代码来源:InvalidBackslashITest.java

示例14: testBindAndUnbindWithDirContextAdapter

import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
@Test
public void testBindAndUnbindWithDirContextAdapter() {
	DirContextAdapter adapter = new DirContextAdapter();
	adapter.setAttributeValues("objectclass", new String[] { "top",
			"person" });
	adapter.setAttributeValue("cn", "Some Person4");
	adapter.setAttributeValue("sn", "Person4");

	tested.bind(DN, adapter, null);
	verifyBoundCorrectData();
	tested.unbind(DN);
	verifyCleanup();
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:14,代码来源:LdapTemplateBindUnbindITest.java

示例15: testBindAndUnbindWithDirContextAdapterUsingLdapName

import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
@Test
public void testBindAndUnbindWithDirContextAdapterUsingLdapName() {
	DirContextAdapter adapter = new DirContextAdapter();
	adapter.setAttributeValues("objectclass", new String[] { "top",
			"person" });
	adapter.setAttributeValue("cn", "Some Person4");
	adapter.setAttributeValue("sn", "Person4");

	tested.bind(LdapUtils.newLdapName(DN), adapter, null);
	verifyBoundCorrectData();
	tested.unbind(LdapUtils.newLdapName(DN));
	verifyCleanup();
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:14,代码来源:LdapTemplateBindUnbindITest.java


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