设为首页 加入收藏

TOP

封装LDAP 增删改查 方法(三)
2014-11-24 02:58:05 来源: 作者: 【 】 浏览:6
Tags:封装 LDAP 删改 方法
lass".equals(mkey))
filter.and(new EqualsFilter(mkey, (String) map.get(mkey)));
}
return filter;
}
/**
* 构造查询实体UUID方法
* @param t
* @return
* @创建人 PengBo
* @创建时间 2013-7-7 下午7:00:49
*/
private Name buildDn(T t) {
String a = t.getDN();
DistinguishedName dn = new DistinguishedName(a);
if(StringUtils.isNotBlank(t.getUuid())){
dn.add("uid", t.getUuid());
}
return dn;
}

/**
* 构造查找组织的dn
* @param t
* @return
* @创建人 PengBo
* @创建时间 2013-7-16 上午9:45:57
*/
public String findDn(T t) {
Name dn= buildDn( t);
return dn.toString();
}
/**
* 查询获得实体属性构造器
* @param t
* @return
* @创建人 PengBo
* @创建时间 2013-7-7 下午7:01:12
*/
private ContextMapper getContextMapper(final T t) {
return new ParameterizedContextMapper() {
@Override
public T mapFromContext(Object ctx) {
DirContextAdapter adapter = (DirContextAdapter) ctx;
T newT=null;
try {
newT = (T) t.getClass().newInstance();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
Map map= t.getMap();
Map smap=new HashMap();
for(String mkey:map.keySet()){
if (!"objectclass".equals(mkey)) {
if(!"userPassword".equals(mkey)){
if (StringUtils.isNotBlank(adapter.getStringAttribute(mkey))) {
smap.put(mkey, adapter.getStringAttribute(mkey));
}else {
smap.put(mkey, null);
}
}
}
}
newT.setMap(smap);
return newT;
}
};
}
}


首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇LDAP 与 MySQL 连用 的JPA事物问题 下一篇轻松了解LDAP的结构概念

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·在 C 语言函数中,如 (2025-12-24 12:19:41)
·C盘里面的AppData文 (2025-12-24 12:19:38)
·c语言中的“%d,%s,%c (2025-12-24 12:19:35)
·Sphinx : 高性能SQL (2025-12-24 10:18:11)
·Pandas 性能优化 - (2025-12-24 10:18:08)