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


Java LDAPConnection.add方法代码示例

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


在下文中一共展示了LDAPConnection.add方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: testAddAnonFail

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

示例3: 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

示例4: testAddAnonFail

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

示例5: testAddBoundSucceed

import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
@Test
public void testAddBoundSucceed() throws Exception {
	LDAPConnection con = new LDAPConnection();
	con.connect("localhost",50983);
	con.bind(3,"cn=admin,dc=domain,dc=com","manager".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);
	
	con.add(entry);
	con.disconnect();
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:17,代码来源:TestACLPlugin.java

示例6: testAddBoundSucceed

import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
public void testAddBoundSucceed() throws Exception {
	LDAPConnection con = new LDAPConnection();
	con.connect("localhost",50983);
	con.bind(3,"cn=admin,dc=domain,dc=com","manager".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);
	
	con.add(entry);
	con.disconnect();
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:16,代码来源:TestACLPlugin.java

示例7: testAdd

import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
public void testAdd() throws Exception {
	LDAPConnection con = new LDAPConnection();
	con.connect("localhost", 50983);
	
	LDIFReader reader = new LDIFReader(new FileInputStream(System.getenv("PROJ_DIR") + "/test/TestJoin/ldifs/joinadd.ldif"));
	LDAPEntry toadd = ((LDAPSearchResult) reader.readMessage()).getEntry();
	
	con.add(toadd);
	
	LDAPSearchResults res = con.search("uid=user4,ou=people,o=mycompany,c=us", 0, "(objectClass=*)", new String[0], false);
	reader = new LDIFReader(new FileInputStream(System.getenv("PROJ_DIR") + "/test/TestJoin/ldifs/afterAdd.ldif"));
	Util util = new Util();
	
	while (res.hasMore()) {
		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 : \nFrom Server\n" + Util.toLDIF(fromserver) + "\n\nFrom LDIF\n" + Util.toLDIF(fromldif));
		}
		
	}
	
	con.delete("uid=user4,ou=people,o=mycompany,c=us");
	
	con.disconnect();
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:34,代码来源:TestJoin.java

示例8: testAdd

import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
@Test
public void testAdd() throws Exception {
	LDAPConnection con = new LDAPConnection();
	con.connect("localhost", 50983);
	
	LDIFReader reader = new LDIFReader(new FileInputStream(System.getenv("PROJ_DIR") + "/test/TestJoin/ldifs/joinadd.ldif"));
	LDAPEntry toadd = ((LDAPSearchResult) reader.readMessage()).getEntry();
	
	con.add(toadd);
	
	LDAPSearchResults res = con.search("uid=user4,ou=people,o=mycompany,c=us", 0, "(objectClass=*)", new String[0], false);
	reader = new LDIFReader(new FileInputStream(System.getenv("PROJ_DIR") + "/test/TestJoin/ldifs/afterAdd.ldif"));
	Util util = new Util();
	
	while (res.hasMore()) {
		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 : \nFrom Server\n" + Util.toLDIF(fromserver) + "\n\nFrom LDIF\n" + Util.toLDIF(fromldif));
		}
		
	}
	
	con.delete("uid=user4,ou=people,o=mycompany,c=us");
	
	con.disconnect();
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:35,代码来源:TestJoin.java

示例9: testAdd

import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
public void testAdd() throws Exception {
	LDAPAttributeSet attribs = new LDAPAttributeSet();
	attribs.add(new LDAPAttribute("objectClass","inetOrgPerson"));
	attribs.add(new LDAPAttribute("uid","testadd"));
	attribs.add(new LDAPAttribute("givenName","test"));
	attribs.add(new LDAPAttribute("sn","add"));
	LDAPAttribute l = new LDAPAttribute("l");
	l.addValue("LA");
	l.addValue("NY");
	attribs.add(l);
	LDAPEntry entry = new LDAPEntry("uid=testadd,dc=nam,dc=compinternal,dc=com",attribs);
	
	LDAPConnection con = new LDAPConnection();
	con.connect("localhost",50983);
	
	con.add(entry);
	
	LDAPSearchResults res = con.search("uid=testadd,dc=nam,dc=compinternal,dc=com", 0, "(objectClass=*)", new String[0], false);
	
	if (! res.hasMore()) {
		fail("Entry not added");
		return;
	}
	
	LDAPEntry fromdir = res.next();
	
	if (res.hasMore()) {
		fail("Entry added too many times?");
		return;
	}
	
	Util util = new Util();
	
	if (! util.compareEntry(fromdir, entry)) {
		fail("Entries not the same : " + fromdir.toString());
	}
	
	con.delete("uid=testadd,dc=nam,dc=compinternal,dc=com");
	
	con.disconnect();
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:42,代码来源:TestJDBC.java

示例10: testAdd

import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
@Test
public void testAdd() throws Exception {
	LDAPAttributeSet attribs = new LDAPAttributeSet();
	attribs.add(new LDAPAttribute("objectClass","inetOrgPerson"));
	attribs.add(new LDAPAttribute("uid","testadd"));
	attribs.add(new LDAPAttribute("givenName","test"));
	attribs.add(new LDAPAttribute("sn","add"));
	LDAPAttribute l = new LDAPAttribute("l");
	l.addValue("LA");
	l.addValue("NY");
	attribs.add(l);
	LDAPEntry entry = new LDAPEntry("uid=testadd,dc=nam,dc=compinternal,dc=com",attribs);
	
	LDAPConnection con = new LDAPConnection();
	con.connect("localhost",50983);
	
	con.add(entry);
	
	LDAPSearchResults res = con.search("uid=testadd,dc=nam,dc=compinternal,dc=com", 0, "(objectClass=*)", new String[0], false);
	
	if (! res.hasMore()) {
		fail("Entry not added");
		return;
	}
	
	LDAPEntry fromdir = res.next();
	
	if (res.hasMore()) {
		fail("Entry added too many times?");
		return;
	}
	
	Util util = new Util();
	
	if (! util.compareEntry(fromdir, entry)) {
		fail("Entries not the same : " + fromdir.toString());
	}
	
	con.delete("uid=testadd,dc=nam,dc=compinternal,dc=com");
	
	con.disconnect();
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:43,代码来源:TestJDBC.java


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