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


Java LDAPException.getResultCode方法代码示例

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


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

示例1: testAddAnonFail

import com.novell.ldap.LDAPException; //导入方法依赖的package包/类
@Test
public void testAddAnonFail() throws Exception {
	LDAPConnection con = new LDAPConnection();
	con.connect("localhost",50983);
	LDAPAttributeSet attribs = new LDAPAttributeSet();
	attribs.add(new LDAPAttribute("cn","Test Add"));
	attribs.add(new LDAPAttribute("sn","Add"));
	attribs.add(new LDAPAttribute("uid","tadd"));
	attribs.add(new LDAPAttribute("objectClass","inetOrgPerson"));
	
	LDAPEntry entry = new LDAPEntry("uid=tadd,ou=users,dc=domain,dc=com",attribs);
	
	try {
		con.add(entry);
	} catch (LDAPException e) {
		if (e.getResultCode() != LDAPException.INSUFFICIENT_ACCESS_RIGHTS) {
			throw e;
		} else {
			return;
		}
	}
	
	fail("add succeeded");
	con.disconnect();
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:26,代码来源:TestACLPlugin.java

示例2: bindPrimary

import com.novell.ldap.LDAPException; //导入方法依赖的package包/类
private void bindPrimary(DistinguishedName dn, Password pwd, LDAPConstraints constraints,
		Bool primaryBindFailed, HashMap<DN, DistinguishedName> boundNameSpaces, BindInterceptorChain bindChain) throws LDAPException {
	try {
		DistinguishedName newBindDN = new DistinguishedName(util.getRemoteMappedDN(dn.getDN(),this.explodedLocalNameSpace,this.explodedPrimaryNamespace));
		bindChain.nextBind(newBindDN,pwd,constraints);
		
		boundNameSpaces.put(this.primaryNamespace, newBindDN);
		primaryBindFailed.setValue(false);
	} catch (LDAPException e) {
		primaryBindFailed.setValue(true);
		if (e.getResultCode() != LDAPException.INVALID_CREDENTIALS) {
			throw e;
		}
	}
	
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:17,代码来源:Joiner.java

示例3: testSearchGroupsBound

import com.novell.ldap.LDAPException; //导入方法依赖的package包/类
@Test
public void testSearchGroupsBound() throws Exception {
	LDAPConnection con = new LDAPConnection();
	con.connect("localhost",50983);
	con.bind(3,"uid=testuser,ou=users,dc=domain,dc=com","secret".getBytes());
	
	
	try {
		LDAPSearchResults res = con.search("ou=groups,dc=domain,dc=com",1,"(objectClass=*)",new String[0],false);
		if (res.hasMore()) {
			fail("has results : " + res.next());
		}
	} catch (LDAPException e) {
		if (e.getResultCode() != LDAPException.INSUFFICIENT_ACCESS_RIGHTS) {
			throw e;
		} else {
			return;
		}
	}
	
	fail ("did not throw error");
	con.disconnect();
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:24,代码来源:TestACLPlugin.java

示例4: compare

import com.novell.ldap.LDAPException; //导入方法依赖的package包/类
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());
		}
	}
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:27,代码来源:Router.java

示例5: testAddAnonFail

import com.novell.ldap.LDAPException; //导入方法依赖的package包/类
public void testAddAnonFail() throws Exception {
	LDAPConnection con = new LDAPConnection();
	con.connect("localhost",50983);
	LDAPAttributeSet attribs = new LDAPAttributeSet();
	attribs.add(new LDAPAttribute("cn","Test Add"));
	attribs.add(new LDAPAttribute("sn","Add"));
	attribs.add(new LDAPAttribute("uid","tadd"));
	attribs.add(new LDAPAttribute("objectClass","inetOrgPerson"));
	
	LDAPEntry entry = new LDAPEntry("uid=tadd,ou=users,dc=domain,dc=com",attribs);
	
	try {
		con.add(entry);
	} catch (LDAPException e) {
		if (e.getResultCode() != LDAPException.INSUFFICIENT_ACCESS_RIGHTS) {
			throw e;
		} else {
			return;
		}
	}
	
	fail("add succeeded");
	con.disconnect();
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:25,代码来源:TestACLPlugin.java

示例6: testSearchGroupsBound

import com.novell.ldap.LDAPException; //导入方法依赖的package包/类
public void testSearchGroupsBound() throws Exception {
	LDAPConnection con = new LDAPConnection();
	con.connect("localhost",50983);
	con.bind(3,"uid=testuser,ou=users,dc=domain,dc=com","secret".getBytes());
	
	
	try {
		LDAPSearchResults res = con.search("ou=groups,dc=domain,dc=com",1,"(objectClass=*)",new String[0],false);
		if (res.hasMore()) {
			fail("has results : " + res.next());
		}
	} catch (LDAPException e) {
		if (e.getResultCode() != LDAPException.INSUFFICIENT_ACCESS_RIGHTS) {
			throw e;
		} else {
			return;
		}
	}
	
	fail ("did not throw error");
	con.disconnect();
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:23,代码来源:TestACLPlugin.java

示例7: testExternalWithInternalBase

import com.novell.ldap.LDAPException; //导入方法依赖的package包/类
@Test
public void testExternalWithInternalBase() throws Exception {
	LDAPConnection con = new LDAPConnection();
	con.connect("127.0.0.1", 50983);
	LDAPSearchResults res = con.search("ou=internal,o=mycompany,c=us",2, "(|(cn=testrouting)([email protected]))", new String[]{}, false);
	
	try {
	if (res.hasMore()) {
		LDAPEntry e1 = res.next();
		fail("Results came back");
	}
	} catch  (LDAPException e) {
		if (e.getResultCode() != 32) {
			throw e;
		}
	}
	
	con.disconnect();
	
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:21,代码来源:TestAttributeRouter.java

示例8: compare

import com.novell.ldap.LDAPException; //导入方法依赖的package包/类
public void compare(CompareInterceptorChain chain, DistinguishedName dn,
		Attribute attrib, LDAPConstraints constraints) throws LDAPException {
	long start = System.currentTimeMillis();
	long end = 0;
	int result = -1;
	Int op = new Int(0);
	Int con = new Int(0);
	
	this.getOpNum(chain.getSession(), con, op);
	
	StringBuffer buf = new StringBuffer("COMPARE op=").append(op.getValue()).append(" con=").append(con.getValue()).append(" dn='").append(dn.getDN()).append("' attribute='").append(attrib.getAttribute().getName()).append("' value='").append(attrib.getAttribute().getName()).append("'");
	
	logger.info(buf.toString());
	
	try {
		chain.nextCompare(dn, attrib, constraints);
		result = 0;
	} catch (LDAPException le) {
		result = le.getResultCode();
		throw le;
	} finally {
		end = System.currentTimeMillis();
		if (result == -1) {
			result = LDAPException.OPERATIONS_ERROR;
		}
		
		buf.setLength(0);
		buf.append("RESULT op=").append(op.getValue()).append(" con=").append(con.getValue()).append(" result=").append(result).append(" time=").append(end-start);
		logger.info(buf.toString());
		
	}

}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:34,代码来源:AccessLog.java

示例9: extendedOperation

import com.novell.ldap.LDAPException; //导入方法依赖的package包/类
public void extendedOperation(ExetendedOperationInterceptorChain chain,
		ExtendedOperation op, LDAPConstraints constraints)
		throws LDAPException {
	long start = System.currentTimeMillis();
	long end = 0;
	int result = -1;
	Int opn = new Int(0);
	Int con = new Int(0);
	
	this.getOpNum(chain.getSession(), con, opn);
	
	StringBuffer buf = new StringBuffer("EXT op=").append(opn.getValue()).append(" con=").append(con.getValue());
	
	logger.info(buf.toString());
	
	try {
		chain.nextExtendedOperations(op, constraints);
		result = 0;
	} catch (LDAPException le) {
		result = le.getResultCode();
		throw le;
	} finally {
		end = System.currentTimeMillis();
		if (result == -1) {
			result = LDAPException.OPERATIONS_ERROR;
		}
		
		buf.setLength(0);
		buf.append("RESULT op=").append(opn.getValue()).append(" con=").append(con.getValue()).append(" result=").append(result).append(" time=").append(end-start);
		logger.info(buf.toString());
		
	}

}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:35,代码来源:AccessLog.java

示例10: modify

import com.novell.ldap.LDAPException; //导入方法依赖的package包/类
public void modify(ModifyInterceptorChain chain, DistinguishedName dn,
		ArrayList<LDAPModification> mods, LDAPConstraints constraints)
		throws LDAPException {
	long start = System.currentTimeMillis();
	long end = 0;
	int result = -1;
	Int op = new Int(0);
	Int con = new Int(0);
	
	this.getOpNum(chain.getSession(), con, op);
	
	StringBuffer buf = new StringBuffer("MOD op=").append(op.getValue()).append(" con=").append(con.getValue()).append(" dn='").append(dn.getDN()).append("'");
	
	logger.info(buf.toString());
	
	try {
		chain.nextModify(dn, mods, constraints);
		result = 0;
	} catch (LDAPException le) {
		result = le.getResultCode();
		throw le;
	} finally {
		end = System.currentTimeMillis();
		if (result == -1) {
			result = LDAPException.OPERATIONS_ERROR;
		}
		
		buf.setLength(0);
		buf.append("RESULT op=").append(op.getValue()).append(" con=").append(con.getValue()).append(" result=").append(result).append(" time=").append(end-start);
		logger.info(buf.toString());
		
	}

}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:35,代码来源:AccessLog.java

示例11: rename

import com.novell.ldap.LDAPException; //导入方法依赖的package包/类
public void rename(RenameInterceptorChain chain, DistinguishedName dn,
		DistinguishedName newRdn, Bool deleteOldRdn,
		LDAPConstraints constraints) throws LDAPException {
	long start = System.currentTimeMillis();
	long end = 0;
	int result = -1;
	Int op = new Int(0);
	Int con = new Int(0);
	
	this.getOpNum(chain.getSession(), con, op);
	
	StringBuffer buf = new StringBuffer("RENAME op=").append(op.getValue()).append(" con=").append(con.getValue()).append(" dn='").append(dn.getDN()).append("'");
	
	logger.info(buf.toString());
	
	try {
		chain.nextRename(dn, newRdn, deleteOldRdn, constraints);
		result = 0;
	} catch (LDAPException le) {
		result = le.getResultCode();
		throw le;
	} finally {
		end = System.currentTimeMillis();
		if (result == -1) {
			result = LDAPException.OPERATIONS_ERROR;
		}
		
		buf.setLength(0);
		buf.append("RESULT op=").append(op.getValue()).append(" con=").append(con.getValue()).append(" result=").append(result).append(" time=").append(end-start);
		logger.info(buf.toString());
		
	}

}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:35,代码来源:AccessLog.java

示例12: compare

import com.novell.ldap.LDAPException; //导入方法依赖的package包/类
public void compare(CompareInterceptorChain chain, DistinguishedName dn,
		Attribute attrib, LDAPConstraints constraints) throws LDAPException {
	
	CacheKey key = new CacheKey(dn.getDN().toString(),new Attribute(attrib.getAttribute().getName(),attrib.getAttribute().getStringValue()));
	
	SimpleCacheEntrySet cacheResults = this.cache.get(key);
	
	if (cacheResults != null) {
		if (! cacheResults.isCompareTrue()) {
			throw new LDAPException("Compare failed",LDAPException.COMPARE_FALSE,"Failed to compare on DN : " + dn.getDN().toString());
		}
	} else {
		try {
			chain.nextCompare(dn, attrib, constraints);
			cacheResults = new SimpleCacheEntrySet(key,true);
			this.cache.put(key, cacheResults);
		} catch (LDAPException ldape) {
			if (ldape.getResultCode() == LDAPException.COMPARE_FALSE || ldape.getResultCode() == LDAPException.COMPARE_TRUE) {
				cacheResults = new SimpleCacheEntrySet(key,(ldape.getResultCode() == LDAPException.COMPARE_TRUE));
				this.cache.put(key, cacheResults);
			}
			
			throw ldape;
		}
	}

}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:28,代码来源:SimpleCache.java

示例13: rename

import com.novell.ldap.LDAPException; //导入方法依赖的package包/类
public void rename(RenameInterceptorChain chain, DistinguishedName dn,
		DistinguishedName newRdn, DistinguishedName newParentDN,
		Bool deleteOldRdn, LDAPConstraints constraints)
		throws LDAPException {
	long start = System.currentTimeMillis();
	long end = 0;
	int result = -1;
	Int op = new Int(0);
	Int con = new Int(0);
	
	this.getOpNum(chain.getSession(), con, op);
	
	StringBuffer buf = new StringBuffer("RENAME op=").append(op.getValue()).append(" con=").append(con.getValue()).append(" dn='").append(dn.getDN()).append("'");
	
	logger.info(buf.toString());
	
	try {
		chain.nextRename(dn, newRdn, newParentDN, deleteOldRdn, constraints);
		result = 0;
	} catch (LDAPException le) {
		result = le.getResultCode();
		throw le;
	} finally {
		end = System.currentTimeMillis();
		if (result == -1) {
			result = LDAPException.OPERATIONS_ERROR;
		}
		
		buf.setLength(0);
		buf.append("RESULT op=").append(op.getValue()).append(" con=").append(con.getValue()).append(" result=").append(result).append(" time=").append(end-start);
		logger.info(buf.toString());
		
	}

}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:36,代码来源:AccessLog.java

示例14: add

import com.novell.ldap.LDAPException; //导入方法依赖的package包/类
public void add(AddInterceptorChain chain, Entry entry,
		LDAPConstraints constraints) throws LDAPException {
	
	long start = System.currentTimeMillis();
	long end = 0;
	int result = -1;
	Int op = new Int(0);
	Int con = new Int(0);
	
	this.getOpNum(chain.getSession(), con, op);
	
	StringBuffer buf = new StringBuffer("ADD op=").append(op.getValue()).append(" con=").append(con.getValue()).append(" dn='").append(entry.getEntry().getDN()).append("'");
	
	logger.info(buf.toString());
	
	try {
		chain.nextAdd(entry, constraints);
		result = 0;
	} catch (LDAPException le) {
		result = le.getResultCode();
		throw le;
	} finally {
		end = System.currentTimeMillis();
		if (result == -1) {
			result = LDAPException.OPERATIONS_ERROR;
		}
		
		buf.setLength(0);
		buf.append("RESULT op=").append(op.getValue()).append(" con=").append(con.getValue()).append(" result=").append(result).append(" time=").append(end-start);
		logger.info(buf.toString());
		
	}

}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:35,代码来源:AccessLog.java

示例15: search

import com.novell.ldap.LDAPException; //导入方法依赖的package包/类
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,"");
	}
	
	
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:76,代码来源:Router.java


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