本文整理汇总了Java中com.novell.ldap.LDAPAttribute.getStringValue方法的典型用法代码示例。如果您正苦于以下问题:Java LDAPAttribute.getStringValue方法的具体用法?Java LDAPAttribute.getStringValue怎么用?Java LDAPAttribute.getStringValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.novell.ldap.LDAPAttribute
的用法示例。
在下文中一共展示了LDAPAttribute.getStringValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generatePosixUser
import com.novell.ldap.LDAPAttribute; //导入方法依赖的package包/类
private void generatePosixUser(PostSearchEntryInterceptorChain chain,
Entry entry, ArrayList<Attribute> attributes, Bool typesOnly,
LDAPSearchConstraints constraints) throws LDAPException {
String addBase = "objectguid=" + entry.getEntry().getAttribute("objectguid").getStringValue() + "," + this.userBase;
LDAPAttributeSet attribs = new LDAPAttributeSet();
attribs.add(new LDAPAttribute("objectClass","posixAccount"));
attribs.add(new LDAPAttribute("objectguid",entry.getEntry().getAttribute("objectguid").getStringValue()));
attribs.add(new LDAPAttribute("loginShell",this.loginShell));
ArrayList<Attribute> homeDirAttribs = new ArrayList<Attribute>();
for (int i=0;i<this.homeDirAttribs.length;i++) {
homeDirAttribs.add(new Attribute(this.homeDirAttribs[i]));
}
Results res = new Results(this.ns.getChain(),this.chainPos + 1);
SearchInterceptorChain schain = chain.createSearchChain(this.chainPos + 1);
schain.nextSearch(new DistinguishedName(entry.getEntry().getDN()), new Int(0), new Filter("(objectClass=*)"), homeDirAttribs, typesOnly, res, constraints);
res.start();
if (! res.hasMore()) {
throw new LDAPException("Entry : " + entry.getEntry().getDN() + " does not exist",LDAPException.OPERATIONS_ERROR,"Operations Error");
}
Entry resEntry = res.next();
String homeDir = this.homeDirTemplate;
for (int i=0;i<this.homeDirAttribs.length;i++) {
LDAPAttribute attrib = resEntry.getEntry().getAttributeSet().getAttribute(this.homeDirAttribs[i]);
if (attrib == null) {
logger.warn("User " + entry.getEntry().getDN() + " does not have the attribute " + this.homeDirAttribs[i]);
homeDir = homeDir.replaceAll("@" + this.homeDirAttribs[i] + "@", "unknown");
} else {
String attribName = "@" + this.homeDirAttribs[i] + "@";
String attribVal = attrib.getStringValue();
attribVal = attribVal.replace("$", "\\$");
homeDir = homeDir.replaceAll(attribName, attribVal);
}
}
while (res.hasMore()) {
res.next();
}
res.finish();
attribs.add(new LDAPAttribute("homeDirectory",homeDir));
chain.createAddChain().nextAdd(new Entry(new LDAPEntry(addBase,attribs)), constraints);
res = new Results(this.ns.getChain(),this.chainPos);
schain = chain.createSearchChain(this.chainPos);
schain.nextSearch(new DistinguishedName(entry.getEntry().getDN()), new Int(0), new Filter("(objectClass=*)"), attributes, typesOnly, res, constraints);
res.start();
if (! res.hasMore()) {
throw new LDAPException("Entry : " + entry.getEntry().getDN() + " does not exist",LDAPException.OPERATIONS_ERROR,"Operations Error");
}
entry.getEntry().getAttributeSet().clear();
entry.getEntry().getAttributeSet().addAll(res.next().getEntry().getAttributeSet());
while (res.hasMore()) {
res.next();
}
res.finish();
}
示例2: dn2attr
import com.novell.ldap.LDAPAttribute; //导入方法依赖的package包/类
private String dn2attr(String dn,InterceptorChain chain) throws LDAPException {
String dnlcase = dn.toLowerCase();
String attr = this.dn2attr.get(dnlcase);
if (attr != null) {
return attr;
} else {
Filter filter = new Filter("(objectClass=*)");
Results results = new Results(this.nameSpace.getRouter().getGlobalChain(),0);
SearchInterceptorChain schain = new SearchInterceptorChain(chain.getBindDN(),chain.getBindPassword(),0,this.nameSpace.getRouter().getGlobalChain(),chain.getSession(),chain.getRequest(),this.nameSpace.getRouter());
ArrayList<Attribute> attributes = new ArrayList<Attribute>();
attributes.add(new Attribute(this.searchAttribute));
schain.nextSearch(new DistinguishedName(dn), new Int(0), filter, attributes, new Bool(false), results, new LDAPSearchConstraints());
results.start();
if (! results.hasMore()) {
logger.warn("DN does not exist : " + dn);
results.finish();
return null;
} else {
Entry entry = results.next();
LDAPAttribute valAttr = entry.getEntry().getAttribute(this.searchAttribute);
if (valAttr == null) {
logger.warn("Attribute " + this.searchAttribute + " does not exist");
results.finish();
return null;
} else {
this.dn2attr.put(dnlcase, valAttr.getStringValue());
results.finish();
return valAttr.getStringValue();
}
}
}
}
示例3: dn2attr
import com.novell.ldap.LDAPAttribute; //导入方法依赖的package包/类
private String dn2attr(String dn,InterceptorChain chain) throws LDAPException {
String dnlcase = dn.toLowerCase();
String attr = this.dn2attr.get(dnlcase);
if (attr != null) {
return attr;
} else {
Filter filter = new Filter("(objectClass=*)");
Results results = new Results(null,chain.getPositionInChain(this) + 1);
SearchInterceptorChain schain = chain.createSearchChain(chain.getPositionInChain(this) + 1);
ArrayList<Attribute> attributes = new ArrayList<Attribute>();
attributes.add(new Attribute(this.newValueAttribute));
schain.nextSearch(new DistinguishedName(dn), new Int(0), filter, attributes, new Bool(false), results, new LDAPSearchConstraints());
results.start();
if (! results.hasMore()) {
logger.warn("DN does not exist : " + dn);
results.finish();
return null;
} else {
Entry entry = results.next();
LDAPAttribute valAttr = entry.getEntry().getAttribute(newValueAttribute);
if (valAttr == null) {
logger.warn("Attribute " + this.newValueAttribute + " does not exist");
results.finish();
return null;
} else {
this.dn2attr.put(dnlcase, valAttr.getStringValue());
results.finish();
return valAttr.getStringValue();
}
}
}
}
示例4: mapIn2Out
import com.novell.ldap.LDAPAttribute; //导入方法依赖的package包/类
private String mapIn2Out(String dn,InterceptorChain chain) throws LDAPException {
Results results = new Results(this.ns.getRouter().getGlobalChain(),0);
SearchInterceptorChain searchChain = new SearchInterceptorChain(chain.getBindDN(),chain.getBindPassword(),this.ns.getRouter().getGlobalChain().getLength(),this.ns.getRouter().getGlobalChain(),chain.getSession(),chain.getRequest(),this.ns.getRouter());
ArrayList<Attribute> nattrs = new ArrayList<Attribute>();
//SearchInterceptorChain searchChain = chain.createSearchChain();
searchChain.nextSearch(new DistinguishedName(dn),new Int(0),new Filter("(objectClass=*)"),nattrs,new Bool(false),results,new LDAPSearchConstraints());
results.start();
if (! results.hasMore()) {
return dn;
} else {
Entry entry = results.next();
while (results.hasMore()) results.next();
LDAPAttribute attr = entry.getEntry().getAttribute(this.joinAttribute);
if (attr != null) {
String joinVal = attr.getStringValue();
String searchFilter = this.searchFilter.replace("#", joinVal);
searchChain = new SearchInterceptorChain(chain.getBindDN(),chain.getBindPassword(),this.ns.getRouter().getGlobalChain().getLength(),this.ns.getRouter().getGlobalChain(),chain.getSession(),chain.getRequest(),this.ns.getRouter());
nattrs = new ArrayList<Attribute>();
searchChain.nextSearch(new DistinguishedName(this.in2outSearchRoot),new Int(2),new Filter(searchFilter),nattrs,new Bool(false),results,new LDAPSearchConstraints());
results.start();
if (! results.hasMore()) {
return dn;
} else {
entry = results.next();
while (results.hasMore()) results.next();
return entry.getEntry().getDN();
}
} else {
//how to handle not mapped
return dn;
}
}
}
示例5: mapOut2In
import com.novell.ldap.LDAPAttribute; //导入方法依赖的package包/类
private String mapOut2In(String dn,InterceptorChain chain) throws LDAPException {
Results results = new Results(this.ns.getRouter().getGlobalChain(),0);
SearchInterceptorChain searchChain = new SearchInterceptorChain(chain.getBindDN(),chain.getBindPassword(),this.ns.getRouter().getGlobalChain().getLength(),this.ns.getRouter().getGlobalChain(),chain.getSession(),chain.getRequest(),this.ns.getRouter());
ArrayList<Attribute> nattrs = new ArrayList<Attribute>();
//SearchInterceptorChain searchChain = chain.createSearchChain();
searchChain.nextSearch(new DistinguishedName(dn),new Int(0),new Filter("(objectClass=*)"),nattrs,new Bool(false),results,new LDAPSearchConstraints());
results.start();
if (! results.hasMore()) {
return dn;
} else {
Entry entry = results.next();
while (results.hasMore()) results.next();
LDAPAttribute attr = entry.getEntry().getAttribute(this.joinAttribute);
if (attr != null) {
String joinVal = attr.getStringValue();
String searchFilter = this.searchFilter.replace("#", joinVal);
searchChain = new SearchInterceptorChain(chain.getBindDN(),chain.getBindPassword(),this.ns.getRouter().getGlobalChain().getLength(),this.ns.getRouter().getGlobalChain(),chain.getSession(),chain.getRequest(),this.ns.getRouter());
nattrs = new ArrayList<Attribute>();
searchChain.nextSearch(new DistinguishedName(this.out2inSearchRoot),new Int(2),new Filter(searchFilter),nattrs,new Bool(false),results,new LDAPSearchConstraints());
results.start();
if (! results.hasMore()) {
return dn;
} else {
entry = results.next();
while (results.hasMore()) results.next();
return entry.getEntry().getDN();
}
} else {
//how to handle not mapped
return dn;
}
}
}