本文整理汇总了Java中com.novell.ldap.LDAPException.NO_SUCH_OBJECT属性的典型用法代码示例。如果您正苦于以下问题:Java LDAPException.NO_SUCH_OBJECT属性的具体用法?Java LDAPException.NO_SUCH_OBJECT怎么用?Java LDAPException.NO_SUCH_OBJECT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.novell.ldap.LDAPException
的用法示例。
在下文中一共展示了LDAPException.NO_SUCH_OBJECT属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compare
public void compare(CompareInterceptorChain chain,DistinguishedName dn,Attribute attrib,LDAPConstraints constraints) throws LDAPException {
ArrayList<NameSpace> localBackends = getLocalLevels(chain, dn);
int num = 0;
Iterator<NameSpace> it = localBackends.iterator();
while (it.hasNext()) {
NameSpace curr = it.next();
CompareInterceptorChain localChain = new CompareInterceptorChain(chain.getBindDN(),chain.getBindPassword(),0,curr.getChain(),chain.getSession(),chain.getRequest());
try {
localChain.nextCompare(dn,attrib,constraints);
} catch (LDAPException e) {
if (e.getResultCode() == LDAPException.NO_SUCH_OBJECT) {
num++;
} else if (e.getResultCode() == LDAPException.COMPARE_TRUE) {
continue;
} else {
throw e;
}
}
if (num == localBackends.size()) {
throw new LDAPException("Could not compare on any services",LDAPException.NO_SUCH_OBJECT,dn.getDN().toString());
}
}
}
示例2: loadRequest
private void loadRequest(InterceptorChain chain, DistinguishedName userdn) throws LDAPException {
SearchInterceptorChain nchain = chain.createSearchChain(chain.getPositionInChain(this));
Results res = new Results(null,chain.getPositionInChain(this));
ArrayList<net.sourceforge.myvd.types.Attribute> attribs = new ArrayList<net.sourceforge.myvd.types.Attribute>();
attribs.add(new Attribute("1.1"));
nchain.nextSearch(userdn, new Int(0), Joiner.OBJ_CLASS_FILTER, attribs, new Bool(false), res, new LDAPSearchConstraints());
res.start();
if (! res.hasMore()) {
res.finish();
throw new LDAPException("Object not found",LDAPException.NO_SUCH_OBJECT,"");
}
LDAPEntry entry = res.next().getEntry();
LDAPAttribute pdn = entry.getAttribute("primaryDN");
chain.getRequest().put(Joiner.MYVD_JOIN_PDN + this.name, new DistinguishedName(pdn.getStringValue()));
ArrayList<DistinguishedName> joinedDns = new ArrayList<DistinguishedName>();
LDAPAttribute jdn = entry.getAttribute("joinedDns");
String[] vals = jdn.getStringValueArray();
for (int i=0;i<vals.length;i++) {
joinedDns.add(new DistinguishedName(vals[i]));
}
chain.getRequest().put(Joiner.MYVD_JOIN_JDN + this.name, joinedDns);
loadRequestADD(chain);
}
示例3: getLocalBackendsWrite
private NameSpace getLocalBackendsWrite(InterceptorChain chain, String dn, boolean isRename) throws LDAPException {
NameSpace curr;
String key = null;
if (isRename) {
key = RequestVariables.ROUTE_NAMESPACE_RENAME;
} else {
key = RequestVariables.ROUTE_NAMESPACE;
}
if (! chain.getRequest().containsKey(key)) {
//logger.info("DN : " + dn);
Level level = this.getLevel(new DN(dn));
if (level == null) {
throw new LDAPException(LDAPException.resultCodeToString(LDAPException.NO_SUCH_OBJECT),LDAPException.NO_SUCH_OBJECT,"");
}
Iterator<NameSpace> it = level.backends.iterator();
curr = it.next();
} else {
curr = this.backends.get(chain.getRequest().get(key));
}
return curr;
}
示例4: bind
public void bind(BindInterceptorChain chain,DistinguishedName dn,Password pwd,LDAPConstraints constraints) throws LDAPException {
//check for an anonymouse user
if (pwd.getValue().length == 0) {
//user has not bind DN
dn.setDN(new DN(""));
return;
}
ArrayList<NameSpace> localBackends = getLocalLevels(chain, dn);
int num = 0;
Iterator<NameSpace> it = localBackends.iterator();
while (it.hasNext()) {
NameSpace curr = it.next();
BindInterceptorChain localChain = new BindInterceptorChain(chain.getBindDN(),chain.getBindPassword(),0,curr.getChain(),chain.getSession(),chain.getRequest());
try {
localChain.nextBind(dn,pwd,constraints);
} catch (LDAPException e) {
if (e.getResultCode() == LDAPException.INVALID_CREDENTIALS || e.getResultCode() == LDAPException.NO_SUCH_OBJECT) {
num++;
} else {
throw e;
}
}
if (num == localBackends.size()) {
throw new LDAPException("Could not bind to any services",LDAPException.INVALID_CREDENTIALS,dn.getDN().toString());
}
}
}
示例5: getLocalLevels
private ArrayList<NameSpace> getLocalLevels(InterceptorChain chain, DistinguishedName dn) throws LDAPException {
ArrayList<NameSpace> localBackends;
logger.debug("Is set namespace?");
if (chain.getRequest().containsKey(RequestVariables.ROUTE_NAMESPACE)) {
logger.debug("namespace manually set");
Object obj = chain.getRequest().get(RequestVariables.ROUTE_NAMESPACE);
if (obj instanceof ArrayList) {
ArrayList<String> list = (ArrayList<String>) obj;
localBackends = new ArrayList<NameSpace>();
Iterator<String> it = list.iterator();
while (it.hasNext()) {
NameSpace lns = this.backends.get(it.next());
if (lns.getBase().getDN().isDescendantOf(dn.getDN()) || dn.getDN().equals(lns.getBase().getDN()) || dn.getDN().isDescendantOf(lns.getBase().getDN())) {
localBackends.add(lns);
}
}
} else if (obj instanceof String) {
localBackends = new ArrayList<NameSpace>();
localBackends.add(this.backends.get((String) obj));
} else {
throw new LDAPException("Invalid routing type",LDAPException.OPERATIONS_ERROR,"");
}
} else {
logger.debug("namespace set by router");
Level level = this.getLevel(dn.getDN());
logger.debug("namespace levels determined");
if (level == null) {
logger.debug("no levels found");
throw new LDAPException(LDAPException.resultCodeToString(LDAPException.NO_SUCH_OBJECT),LDAPException.NO_SUCH_OBJECT,"");
}
localBackends = level.backends;
}
return localBackends;
}
示例6: getId
private int getId(DistinguishedName dn, Connection con) throws SQLException, LDAPException {
PreparedStatement ps = con.prepareStatement("SELECT id FROM USERS WHERE username=?");
String uid = ((RDN) dn.getDN().getRDNs().get(0)).getValue();
ps.setString(1, uid);
ResultSet rs = ps.executeQuery();
if (! rs.next()) {
throw new LDAPException("User " + uid + " not found",LDAPException.NO_SUCH_OBJECT,"No such object");
}
int id = rs.getInt("id");
rs.close();
ps.close();
return id;
}
示例7: getInternalDN
private DN getInternalDN(DN externalDN,InterceptorChain chain,LDAPEntry toadd) throws LDAPException {
Vector<RDN> externalRDNs = externalDN.getRDNs();
//check to make sure we need to do the mapping
if (externalRDNs.size() == 0 || ! externalRDNs.get(0).getType().equalsIgnoreCase(this.externalRDN)) {
return externalDN;
}
//check to see if we have it cached
String dnstr = this.out2in.get(externalDN.toString().toLowerCase());
if (dnstr != null) {
return new DN(dnstr);
}
//we need to retrieve the attribute via a search
Results results = new Results(null,chain.getPositionInChain(this));
SearchInterceptorChain schain = chain.createSearchChain(chain.getPositionInChain(this));
DN base = new DN();
for (int i=1,m=externalRDNs.size();i<m;i++) {
base.addRDNToBack(externalRDNs.get(i));
}
String val = "";
if (toadd == null) {
ArrayList<Attribute> attributes = new ArrayList<Attribute>();
attributes.add(new Attribute(this.internalRDN));
Filter filter = new Filter("(" + this.externalRDN + "=" + externalRDNs.get(0).getValue() +")");
schain.nextSearch(new DistinguishedName(base), new Int(1), filter, attributes, new Bool(false), results, new LDAPSearchConstraints());
results.start();
Entry entry = null;
if (results.hasMore()) {
entry = results.next();
} else {
results.finish();
throw new LDAPException("No Such Object",LDAPException.NO_SUCH_OBJECT,"No Such Object");
}
val = entry.getEntry().getAttribute(this.internalRDN).getStringValue();
} else {
val = toadd.getAttribute(this.internalRDN).getStringValue();
}
DN internalDN = new DN();
RDN rdn = new RDN();
rdn.add(this.internalRDN, val, val);
internalDN.addRDN(rdn);
for (int i=1,m=externalRDNs.size();i<m;i++) {
internalDN.addRDNToBack(externalRDNs.get(i));
}
this.out2in.put(externalDN.toString().toLowerCase(), internalDN.toString());
return internalDN;
}
示例8: extendedOperation
public void extendedOperation(ExetendedOperationInterceptorChain chain,ExtendedOperation op,LDAPConstraints constraints) throws LDAPException {
Iterator<NameSpace> itBase = null;
Iterator<java.util.Map.Entry<String, NameSpace>> itNoBase = null;
Iterator<?> it;
if (op.getDn() != null || chain.getRequest().containsKey(RequestVariables.ROUTE_NAMESPACE)) {
if (chain.getRequest().containsKey(RequestVariables.ROUTE_NAMESPACE)) {
itBase = this.getLocalLevels(chain,op.getDn()).iterator();
} else {
itBase = this.getLevel(op.getDn().getDN()).backends.iterator();
}
it = itBase;
} else {
itNoBase = this.backends.entrySet().iterator();
it = itNoBase;
}
int num = 0;
while (it.hasNext()) {
NameSpace curr = null;
if (itBase != null) {
curr = itBase.next();
} else {
curr = itNoBase.next().getValue();
}
ExetendedOperationInterceptorChain localChain = new ExetendedOperationInterceptorChain(chain.getBindDN(),chain.getBindPassword(),0,curr.getChain(),chain.getSession(),chain.getRequest());
try {
localChain.nextExtendedOperations(op,constraints);
} catch (LDAPException e) {
if (e.getResultCode() == LDAPException.NO_SUCH_OBJECT) {
num++;
}
}
if (! this.writeAll) {
continue;
}
if (num == this.backends.size()) {
throw new LDAPException("Could not compare on any services",LDAPException.NO_SUCH_OBJECT,"");
}
}
}
示例9: search
public void search(SearchInterceptorChain chain,DistinguishedName base,Int scope,Filter filter,ArrayList<Attribute> attributes,Bool typesOnly,Results results,LDAPSearchConstraints constraints) throws LDAPException {
logger.debug("Entering router search");
int notFounds = 0;
HashSet<String> toExclude = (HashSet<String>) chain.getRequest().get(RequestVariables.ROUTE_NAMESPACE_EXCLUDE);
logger.debug("Determining local levels");
ArrayList<NameSpace> localBackends = this.getLocalLevels(chain,base);
logger.debug("Determined local levels");
Iterator<NameSpace> it = localBackends.iterator();
logger.debug("Iterate over levels");
while (it.hasNext()) {
NameSpace holder = it.next();
if (toExclude != null && toExclude.contains(holder.getLabel())) {
continue;
}
DN parentDN = holder.getBase().getDN().getParent();
DN reqDN = new DN(base.toString());
DistinguishedName searchBase = new DistinguishedName(reqDN.toString());
logger.debug("Determine scope");
Int localScope = new Int(scope.getValue());
if (scope.getValue() != 0) {
if (scope.getValue() == 1) {
if (holder.getBase().getDN().countRDNs() - searchBase.getDN().countRDNs() == 1) {
localScope.setValue(0);
searchBase = new DistinguishedName(holder.getBase().getDN().toString());
} else if (holder.getBase().getDN().countRDNs() - searchBase.getDN().countRDNs() > 0) {
continue;
}
} else {
searchBase = base;
}
}
logger.debug("Base determined");
try {
logger.debug("create local chain");
SearchInterceptorChain localChain = new SearchInterceptorChain(chain.getBindDN(),chain.getBindPassword(),0,holder.getChain(),chain.getSession(),chain.getRequest());
logger.debug("Begin Local Chain");
localChain.nextSearch(searchBase,localScope,filter,attributes,typesOnly,results,constraints);
logger.debug("chain complete");
} catch (LDAPException e) {
logger.error("Error running search",e);
if (e.getResultCode() == 32) {
notFounds++;
} else {
throw e;
}
}
if (scope.getValue() == 0) {
break;
}
}
if (notFounds == localBackends.size()) {
throw new LDAPException("Could not find base",LDAPException.NO_SUCH_OBJECT,"");
}
}
示例10: add
public void add(AddInterceptorChain chain,Entry entry,LDAPConstraints constraints) throws LDAPException {
NameSpace curr = null;
curr = getLocalBackendsWrite(chain, entry.getEntry().getDN());
if (curr == null) {
throw new LDAPException("No namespaces for " + entry.getEntry().getDN().toString(),LDAPException.NO_SUCH_OBJECT,entry.getEntry().getDN().toString());
}
AddInterceptorChain localChain = new AddInterceptorChain(chain.getBindDN(),chain.getBindPassword(),0,curr.getChain(),chain.getSession(),chain.getRequest());
localChain.nextAdd(entry,constraints);
}
示例11: rename
public void rename(RenameInterceptorChain chain,DistinguishedName dn,DistinguishedName newRdn, DistinguishedName newParentDN, Bool deleteOldRdn,LDAPConstraints constraints) throws LDAPException {
DN oldDN = new DN(dn.getDN().toString());
DN newPDN = new DN(newParentDN.getDN().toString());
NameSpace oldNs = this.getLocalBackendsWrite(chain,dn.getDN().toString());
NameSpace newNs = this.getLocalBackendsWrite(chain,newPDN.toString(),true);
if (oldNs == newNs) {
RenameInterceptorChain newChain = new RenameInterceptorChain(chain.getBindDN(),chain.getBindPassword(),0,oldNs.getChain(),chain.getSession(),chain.getRequest());
newChain.nextRename(dn,newRdn,newParentDN,deleteOldRdn,constraints);
} else {
SearchInterceptorChain searchChain = new SearchInterceptorChain(chain.getBindDN(),chain.getBindPassword(),0,oldNs.getChain(),chain.getSession(),chain.getRequest());
Results results = new Results(globalChain);
searchChain.nextSearch(new DistinguishedName(dn.getDN().toString()),new Int(0),new Filter("(objectClass=*)"),new ArrayList<Attribute>(),new Bool(false),results,new LDAPSearchConstraints());
results.start();
if (! results.hasMore()) {
throw new LDAPException("Old entry not found",LDAPException.NO_SUCH_OBJECT,"");
}
Entry entry = results.next();
results.finish();
AddInterceptorChain addChain = new AddInterceptorChain(chain.getBindDN(),chain.getBindPassword(),0,newNs.getChain(),chain.getSession(),chain.getRequest());
LDAPEntry newEntry = new LDAPEntry(newRdn.getDN().toString() + "," + newParentDN.getDN().toString(),entry.getEntry().getAttributeSet());
RDN rdn = new RDN(newRdn.getDN().toString());
RDN oldRDN = (RDN) dn.getDN().getRDNs().get(0);
newEntry.getAttributeSet().getAttribute(rdn.getType()).removeValue(oldRDN.getValue());
newEntry.getAttributeSet().getAttribute(rdn.getType()).addValue(rdn.getValue());
entry = new Entry(newEntry);
addChain.nextAdd(entry,new LDAPConstraints());
if (deleteOldRdn.getValue()) {
DeleteInterceptorChain delChain = new DeleteInterceptorChain(chain.getBindDN(),chain.getBindPassword(),0,oldNs.getChain(),chain.getSession(),chain.getRequest());
delChain.nextDelete(dn,new LDAPConstraints());
}
}
}