本文整理汇总了Java中org.springframework.ldap.core.DirContextAdapter.setAttributeValue方法的典型用法代码示例。如果您正苦于以下问题:Java DirContextAdapter.setAttributeValue方法的具体用法?Java DirContextAdapter.setAttributeValue怎么用?Java DirContextAdapter.setAttributeValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.ldap.core.DirContextAdapter
的用法示例。
在下文中一共展示了DirContextAdapter.setAttributeValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例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);
}
示例3: createUser
import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
private void createUser(String username) throws UnsupportedEncodingException {
DirContextAdapter ctx = new DirContextAdapter(new DistinguishedName(OU_DN).append("cn", username));
ctx.addAttributeValue("objectclass", "top");
ctx.addAttributeValue("objectclass", "person");
ctx.addAttributeValue("objectclass", "organizationalPerson");
ctx.addAttributeValue("objectclass", "user");
ctx.setAttributeValue("givenName", username);
ctx.setAttributeValue("userPrincipalName", username + "@example.com");
ctx.setAttributeValue("cn", username);
ctx.setAttributeValue("description", "Dummy user");
ctx.setAttributeValue("sAMAccountName", username.toUpperCase() + "." + username.toUpperCase());
ctx.setAttributeValue("userAccountControl", "512");
String newQuotedPassword = "\"" + DEFAULT_PASSWORD + "\"";
ctx.setAttributeValue("unicodePwd", newQuotedPassword.getBytes("UTF-16LE"));
ldapTemplate.bind(ctx);
}
示例4: 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();
}
}
示例5: 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"));
}
}
示例6: createUserContext
import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
private DirContextAdapter createUserContext(String realm, User user) {
DirContextAdapter context = new DirContextAdapter(buildUserDN(realm, user));
boolean isCreate = true;
mapUserToContext(context, user, isCreate);
context.setAttributeValue("cn", user.getCn());
return context;
}
示例7: 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);
}
示例8: testModifyAttributes_DirContextAdapter
import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
/**
* Demonstrates how the DirContextAdapter can be used to automatically keep
* track of changes of the attributes and deliver ModificationItems to use
* in moifyAttributes().
*/
@Test
public void testModifyAttributes_DirContextAdapter() throws Exception {
DirContextAdapter adapter = (DirContextAdapter) tested.lookup(PERSON4_DN);
adapter.setAttributeValue("description", "Some other description");
ModificationItem[] modificationItems = adapter.getModificationItems();
tested.modifyAttributes(PERSON4_DN, modificationItems);
verifyBoundCorrectData();
}
示例9: mapToContext
import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
private void mapToContext(Person person, DirContextAdapter context) {
context.setAttributeValues("objectclass", new String[] { "top", "person" });
context.setAttributeValue("cn", person.getFullName());
context.setAttributeValue("sn", person.getLastName());
context.setAttributeValue("description", person.getDescription());
context.setAttributeValue("telephoneNumber", person.getPhone());
}
示例10: 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();
}
示例11: 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");
}
示例12: 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 });
}
示例13: updateAndRename
import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
public void updateAndRename(String dn, String newDn, String description) {
DirContextAdapter ctx = (DirContextAdapter) ldapTemplate.lookup(dn);
ctx.setAttributeValue("description", description);
ldapTemplate.modifyAttributes(ctx);
ldapTemplate.rename(dn, newDn);
}
示例14: modifyAttributes
import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
public void modifyAttributes(String dn, String lastName, String description) {
DirContextAdapter ctx = (DirContextAdapter) ldapTemplate.lookup(dn);
ctx.setAttributeValue("sn", lastName);
ctx.setAttributeValue("description", description);
ldapTemplate.modifyAttributes(dn, ctx.getModificationItems());
}
示例15: testBindAndUnbind
import org.springframework.ldap.core.DirContextAdapter; //导入方法依赖的package包/类
@Test
public void testBindAndUnbind() {
DirContextAdapter adapter = new DirContextAdapter();
adapter.setAttributeValues("objectclass", new String[] { "top", "person" });
adapter.setAttributeValue("cn", "Some Person4");
adapter.setAttributeValue("sn", "Person4");
ldapTemplate.bind(DN_STRING, adapter, null);
verifyBoundCorrectData();
ldapTemplate.unbind(DN_STRING);
verifyCleanup();
}