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


Java LDAPConnection.bind方法代码示例

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


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

示例1: testAddBoundFail

import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
@Test
public void testAddBoundFail() throws Exception {
	LDAPConnection con = new LDAPConnection();
	con.connect("localhost",50983);
	con.bind(3,"uid=testuser,ou=users,dc=domain,dc=com","secret".getBytes());
	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,代码行数:27,代码来源:TestACLPlugin.java

示例2: testAddBoundFail

import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
public void testAddBoundFail() throws Exception {
	LDAPConnection con = new LDAPConnection();
	con.connect("localhost",50983);
	con.bind(3,"uid=testuser,ou=users,dc=domain,dc=com","secret".getBytes());
	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

示例3: testSearchUsersBound

import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
public void testSearchUsersBound() throws Exception {
	LDAPConnection con = new LDAPConnection();
	con.connect("localhost",50983);
	con.bind(3,"uid=testuser,ou=users,dc=domain,dc=com","secret".getBytes());
	
	LDAPAttributeSet attribs = new LDAPAttributeSet();
	attribs.add(new LDAPAttribute("objectClass","inetOrgPerson"));
	attribs.add(new LDAPAttribute("cn","Test User1"));
	attribs.add(new LDAPAttribute("sn","User1"));
	attribs.add(new LDAPAttribute("uid","testuser1"));
	attribs.add(new LDAPAttribute("l","location1"));
	
	LDAPSearchResults res = con.search("ou=users,dc=domain,dc=com",1,"(uid=testuser1)",new String[0],false);
	if (! res.hasMore()) {
		fail("no results");
	}
	
	LDAPEntry fromServer = res.next();
	LDAPEntry control = new LDAPEntry("uid=testuser1,ou=users,dc=domain,dc=com",attribs);
	
	if (! Util.compareEntry(fromServer,control)) {
		fail("invalid entry : " + fromServer.toString());
	}
	con.disconnect();
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:26,代码来源:TestACLPlugin.java

示例4: testSearchGroupsBound

import com.novell.ldap.LDAPConnection; //导入方法依赖的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

示例5: testUpdateEntry

import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
public void testUpdateEntry() throws LDAPException {
	LDAPConnection con = new LDAPConnection();
	con.connect("localhost",50983);
	con.bind(3,"cn=admin,o=mycompany,c=us","manager".getBytes());
	
	LDAPAttributeSet attribs = new LDAPAttributeSet();
	
	
	LDAPEntry entry = new LDAPEntry("cn=testadd,o=mycompany,c=us",attribs);
	LDAPSearchResults res = con.search("o=mycompany,c=us",2,"(uid=testuid)",new String[] {"updateentry"},false);
	LDAPEntry fromServer = res.next();
	if (! Util.compareEntry(entry,fromServer)) {
		fail("Did not retrieve correct data : " + fromServer.toString());
	}
	con.disconnect();
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:17,代码来源:TestJDBCLDAP.java

示例6: testUpdateEntry

import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
@Test
public void testUpdateEntry() throws LDAPException {
	LDAPConnection con = new LDAPConnection();
	con.connect("localhost",50983);
	con.bind(3,"cn=admin,o=mycompany,c=us","manager".getBytes());
	
	LDAPAttributeSet attribs = new LDAPAttributeSet();
	
	
	LDAPEntry entry = new LDAPEntry("cn=testadd,o=mycompany,c=us",attribs);
	LDAPSearchResults res = con.search("o=mycompany,c=us",2,"(uid=testuid)",new String[] {"updateentry"},false);
	LDAPEntry fromServer = res.next();
	if (! Util.compareEntry(entry,fromServer)) {
		fail("Did not retrieve correct data : " + fromServer.toString());
	}
	con.disconnect();
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:18,代码来源:TestJDBCLDAP.java

示例7: testDelete

import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
@Test
public void testDelete() throws LDAPException {
	LDAPConnection con = new LDAPConnection();
	con.connect("localhost",50983);
	con.bind(3,"cn=admin,o=mycompany,c=us","manager".getBytes());
	
	LDAPAttributeSet attribs = new LDAPAttributeSet();

	
	LDAPEntry entry = new LDAPEntry("cn=testadd,o=mycompany,c=us",attribs);
	LDAPSearchResults res = con.search("o=mycompany,c=us",2,"(sn=add)",new String[] {"delete"},false);
	LDAPEntry fromServer = res.next();
	if (! Util.compareEntry(entry,fromServer) || res.hasMore()) {
		fail("Did not retrieve correct data : " + fromServer.toString());
	}
	con.disconnect();
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:18,代码来源:TestJDBCLDAP.java

示例8: testAdminBind

import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
public void testAdminBind() throws Exception {
	LDAPConnection con = new LDAPConnection();
	con.connect("127.0.0.1", 50983);
	
	con.bind(3,"cn=admin,dc=domain,dc=com", "manager".getBytes());
	con.disconnect();
	
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:9,代码来源:TestRouteCredentials.java

示例9: testBindUser

import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
public void testBindUser() throws Exception {
	LDAPConnection con = new LDAPConnection();
	con.connect("localhost", 50983);
	LDAPSearchResults res = con.search("dc=domain,dc=com", 2, "(&(objectClass=posixAccount)(uid=tuser001))", new String[0], false);
	LDIFReader reader = new LDIFReader(new FileInputStream(System.getenv("PROJ_DIR") + "/test/TestADPosix/userSearch.ldif"));
	Util util = new Util();
	String DN = "";
	boolean found = false;
	
	while (res.hasMore()) {
		found = true;
		LDAPMessage msg = reader.readMessage();
		if (msg == null) {
			fail("number of results dont match");
			return;
		}
		
		
		LDAPEntry fromldif = ((LDAPSearchResult) msg).getEntry();
		LDAPEntry fromserver = res.next();
		if (! util.compareEntry(fromserver, fromldif)) {
			fail("Entries don't match\n from server: \n" + util.toLDIF(fromserver) + "\nfromldif:\n" + util.toLDIF(fromldif));
		}
		
		DN = fromserver.getDN();
		
	}
	
	try {
		con.bind(3,DN, "secret".getBytes());
	} catch (LDAPException e) {
		fail("failed to bind: " + e.toString());
	}
	
	con.disconnect();
	
	if (! found) {
		fail("no entries returned");
	}
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:41,代码来源:TestJoinAD.java

示例10: testDelete

import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
public void testDelete() throws LDAPException {

		HashMap session = new HashMap();
		session.put(SessionVariables.BOUND_INTERCEPTORS,new ArrayList<String>());
		DeleteInterceptorChain chain = new DeleteInterceptorChain(
				new DistinguishedName(new DN("cn=admin,o=mycompany,c=us")),
				new Password("manager".getBytes()), 0, this.chain,
				session, new HashMap<Object, Object>());

		chain.nextDelete(new DistinguishedName(
				"cn=Test User,ou=internal,o=company"), new LDAPConstraints());

		LDAPConnection con = new LDAPConnection();
		con.connect("localhost", 10983);
		con.bind(3, "cn=admin,dc=domain,dc=com", "manager".getBytes());

		try {
			LDAPSearchResults res = con.search(
					"cn=Test User,ou=internal,o=company,c=us", 0,
					"(objectClass=*)", new String[0], false);
			LDAPEntry result = res.next();
			fail("Entry not deleted");
		} catch (LDAPException e) {

		}
		
		con.disconnect();

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

示例11: testDelete

import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
public void testDelete() throws LDAPException {
	HashMap session = new HashMap();
	session.put(SessionVariables.BOUND_INTERCEPTORS,new ArrayList<String>());
	DeleteInterceptorChain chain = new DeleteInterceptorChain(
			new DistinguishedName(new DN("cn=admin,o=mycompany,c=us")),
			new Password("manager".getBytes()), 0, null,
			session, new HashMap<Object, Object>());

	router.delete(chain,
			new DistinguishedName("ou=internal,o=company,c=us"),
			new LDAPConstraints());

	LDAPConnection con = new LDAPConnection();
	con.connect("localhost", 10983);
	con.bind(3, "cn=admin,dc=domain,dc=com", "manager".getBytes());

	try {
		LDAPSearchResults res = con.search(
				"cn=Test User,ou=internal,o=company,c=us", 0,
				"(objectClass=*)", new String[0], false);
		LDAPEntry result = res.next();
		fail("Entry not deleted");
	} catch (LDAPException e) {

	}

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

示例12: reloadAllData

import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
public void reloadAllData() throws Exception {
	
	LDAPConnection con = new LDAPConnection();
	con.connect("127.0.0.1", this.port);
	con.bind(this.adminDN, this.adminPass);
	LDIFReader reader = new LDIFReader(new FileInputStream(fullPath + "/data.ldif"));
	
	
	LDAPMessage msg = reader.readMessage();
	this.deleteNode(((LDAPSearchResult) msg).getEntry().getDN(), con,true);
	con.disconnect();
	
	
	
	this.loadLDIF(fullPath,adminDN,adminPass,port,true);
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:17,代码来源:StartOpenLDAP.java

示例13: testSearchGroupsNoException

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

示例14: testExtendedOp

import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
@Test
	public void testExtendedOp() throws IOException, LDAPException {
//		 first we weill run the extended operation
		ByteArrayOutputStream encodedData = new ByteArrayOutputStream();
		LBEREncoder encoder = new LBEREncoder();

		// we are using the "real" base as the ldap context has no way of
		// knowing how to parse the operation
		ASN1Tagged[] seq = new ASN1Tagged[3];
		seq[0] = new ASN1Tagged(new ASN1Identifier(ASN1Identifier.CONTEXT,
				false, 0), new ASN1OctetString(
				"cn=Test User,ou=internal,o=mycompany,c=us"), false);
		seq[1] = new ASN1Tagged(new ASN1Identifier(ASN1Identifier.CONTEXT,
				false, 1), new ASN1OctetString("secret"), false);
		seq[2] = new ASN1Tagged(new ASN1Identifier(ASN1Identifier.CONTEXT,
				false, 2), new ASN1OctetString("mysecret"), false);

		ASN1Sequence opSeq = new ASN1Sequence(seq, 3);
		opSeq.encode(encoder, encodedData);

		LDAPExtendedOperation op = new LDAPExtendedOperation(
				"1.3.6.1.4.1.4203.1.11.1", encodedData.toByteArray());
		ExtendedOperation localOp = new ExtendedOperation(new DistinguishedName(""), op);

		HashMap session = new HashMap();
		session.put(SessionVariables.BOUND_INTERCEPTORS,
				new ArrayList<String>());
		ExetendedOperationInterceptorChain extChain = new ExetendedOperationInterceptorChain(
				new DistinguishedName(""), new Password(""), 0,
				globalChain, session, new HashMap<Object, Object>(),router);

		extChain.nextExtendedOperations(localOp,new LDAPConstraints());
		

		

		try {
			LDAPConnection con = new LDAPConnection();
			con.connect("localhost",11983);
			con.bind(3,"cn=Test User,ou=internal,dc=domain,dc=com","mysecret".getBytes());

		} catch (LDAPException e) {

			fail("Invalid error " + e.toString());

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

示例15: testLinuxLogin

import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
@Test
public void testLinuxLogin() throws Exception {
	LDAPConnection con = new LDAPConnection();
	con.connect("localhost", 50983);
	
	//need to pre-search to keep the numeric ids
	LDAPSearchResults res = con.search("o=mycompany,c=us", 2, "(objectClass=*)", new String[0], false);
	checkSearch(res,"fulldir.ldif");
	
	//nismap test
	res = con.search("cn=users,o=mycompany,c=us", 2, "(&(objectclass=nisMap)(nisMapName=auto.master))", new String[]{"1.1"}, false);
	if (res.hasMore()) {
		fail("Should be no resutls");
	}
	
	//system account, not existant
	res = con.search("cn=users,o=mycompany,c=us", 2, "(&(objectClass=posixAccount)(uid=gdm))", new String[]{}, false);
	if (res.hasMore()) {
		fail("Should be no resutls");
	}
	
	//system acount's group, non existant
	res = con.search("cn=users,o=mycompany,c=us", 2, "(&(objectClass=posixGroup)(memberUid=gdm))", new String[]{"gidNumber"}, false);
	if (res.hasMore()) {
		fail("Should be no resutls");
	}
	
	//user typed in their username
	res = con.search("cn=users,o=mycompany,c=us",2,"(uid=mlb)",new String[] {},false);
	String str = this.checkSearch(res, "uidSearch.ldif");
	if (str.length() > 0) {
		fail(str);
	}
	
	//search and bind
	res = con.search("cn=users,o=mycompany,c=us",2,"(uid=mlb)",new String[] {},false);
	res.hasMore();
	LDAPEntry entry = res.next();
	String dn = entry.getDN();
	
	if(res.hasMore()) {
		fail("more then one user returned");
	}
	
	con.bind(3,dn, "mlbsecret".getBytes());
	
	//rebind as anon
	con.bind(3, "", new byte[0]);
	
	
	res = con.search("cn=users,o=mycompany,c=us", 2, "(&(objectClass=posixAccount)(uidNumber=505))", new String[] {"uid","uidNumber","gidNumber","cn","homeDirectory","loginShell","gecos","description","objectClass","userPassword"}, false);
	str = this.checkSearch(res, "uidNumberSearch.ldif");
	if (str.length() > 0) {
		fail(str);
	}
	
	res = con.search("cn=users,o=mycompany,c=us",2,"(&(objectClass=posixAccount)(uid=mlb))",new String[] {},false);
	str = this.checkSearch(res, "uidSearch.ldif");
	if (str.length() > 0) {
		fail(str);
	}
	
	//group memberships?
	res = con.search("cn=users,o=mycompany,c=us",2,"(&(objectClass=posixGroup)(|(memberUid=mlb)(uniqueMember=cn=Marc Boorshtein,cn=Users,o=mycompany,c=us)))",new String[] {"gidNumber"},false);
	str = this.checkSearch(res, "groupMemberships.ldif");
	if (str.length() > 0) {
		fail(str);
	}
	
	
	
	con.disconnect();
	
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:75,代码来源:ADPosix.java


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