本文整理汇总了Java中com.novell.ldap.LDAPEntry类的典型用法代码示例。如果您正苦于以下问题:Java LDAPEntry类的具体用法?Java LDAPEntry怎么用?Java LDAPEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LDAPEntry类属于com.novell.ldap包,在下文中一共展示了LDAPEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSearchPrimary
import com.novell.ldap.LDAPEntry; //导入依赖的package包/类
@Test
public void testSearchPrimary() throws Exception {
LDAPConnection con = new LDAPConnection();
con.connect("localhost", 50983);
LDAPSearchResults res = con.search("o=mycompany,c=us", 2, "(cn=Test User2)", new String[0], false);
LDIFReader reader = new LDIFReader(new FileInputStream(System.getenv("PROJ_DIR") + "/test/TestJoin/ldifs/filterPrimary.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 : " + fromserver + "/" + fromldif);
}
}
con.disconnect();
}
示例2: testSearchUsersBound
import com.novell.ldap.LDAPEntry; //导入依赖的package包/类
@Test
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();
}
示例3: mapEntry
import com.novell.ldap.LDAPEntry; //导入依赖的package包/类
public LDAPEntry mapEntry(LDAPEntry origEntry,boolean outbound) {
NamingUtils util = new NamingUtils();
LDAPAttributeSet nattribs = new LDAPAttributeSet();
LDAPAttributeSet origAttribs = origEntry.getAttributeSet();
Iterator it = origAttribs.iterator();
while (it.hasNext()) {
LDAPAttribute origAttrib = (LDAPAttribute) it.next();
LDAPAttribute nattrib = mapAttribute(outbound, util, origAttrib);
nattribs.add(nattrib);
}
return new LDAPEntry(origEntry.getDN(),nattribs);
}
示例4: toLDIF
import com.novell.ldap.LDAPEntry; //导入依赖的package包/类
public static String toLDIF(LDAPEntry entry) {
StringBuffer buf = new StringBuffer();
buf.append("dn: ").append(entry.getDN()).append('\n');
LDAPAttributeSet attrs = entry.getAttributeSet();
Iterator<LDAPAttribute> it = attrs.iterator();
while (it.hasNext()) {
LDAPAttribute attr = it.next();
Enumeration enumer = attr.getStringValues();
while (enumer.hasMoreElements()) {
buf.append(attr.getName()).append(": ").append(enumer.nextElement()).append('\n');
}
}
return buf.toString();
}
示例5: testAddAnonFail
import com.novell.ldap.LDAPEntry; //导入依赖的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();
}
示例6: testAddBoundFail
import com.novell.ldap.LDAPEntry; //导入依赖的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();
}
示例7: testReadSchema
import com.novell.ldap.LDAPEntry; //导入依赖的package包/类
@Test
public void testReadSchema() throws Exception {
LDAPConnection con = new LDAPConnection();
con.connect("127.0.0.1", 50983);
LDAPSearchResults res = con.search("cn=schema", 0, "(objectClass=*)", new String[0], false);
res.hasMore();
LDAPEntry fromserver = res.next();
con.disconnect();
LDIFReader reader = new LDIFReader(new FileInputStream(System.getenv("PROJ_DIR") + "/dist/conf/openldap_schema.ldif"));
Util util = new Util();
LDAPMessage msg = reader.readMessage();
if (msg == null) {
fail("number of results dont match");
return;
}
LDAPEntry fromldif = ((LDAPSearchResult) msg).getEntry();
if (! util.compareEntry(fromserver, fromldif)) {
fail("Entries don't match\n from server: \n" + util.toLDIF(fromserver) + "\nfromldif:\n" + util.toLDIF(fromldif));
}
}
示例8: testSearchJoined
import com.novell.ldap.LDAPEntry; //导入依赖的package包/类
public void testSearchJoined() throws Exception {
LDAPConnection con = new LDAPConnection();
con.connect("localhost", 50983);
LDAPSearchResults res = con.search("o=mycompany,c=us", 2, "(appattrib1=sysx)", new String[0], false);
LDIFReader reader = new LDIFReader(new FileInputStream(System.getenv("PROJ_DIR") + "/test/TestJoin/ldifs/filterJoined.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.disconnect();
}
示例9: testBaseSearch
import com.novell.ldap.LDAPEntry; //导入依赖的package包/类
public void testBaseSearch() throws Exception {
LDAPConnection con = new LDAPConnection();
con.connect("localhost", 50983);
LDAPSearchResults res = con.search("uid=user3,ou=people,o=mycompany,c=us", 0, "(objectClass=*)", new String[0], false);
LDIFReader reader = new LDIFReader(new FileInputStream(System.getenv("PROJ_DIR") + "/test/TestJoin/ldifs/baseSearch.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 : " + fromserver + "/" + fromldif);
}
}
con.disconnect();
}
示例10: testSearchPickAttribs
import com.novell.ldap.LDAPEntry; //导入依赖的package包/类
public void testSearchPickAttribs() throws Exception {
LDAPConnection con = new LDAPConnection();
con.connect("localhost", 50983);
LDAPSearchResults res = con.search("o=mycompany,c=us", 2, "(appattrib1=sysx)", new String[] {"cn","appattrib1","appattrib2"}, false);
LDIFReader reader = new LDIFReader(new FileInputStream(System.getenv("PROJ_DIR") + "/test/TestJoin/ldifs/pickAttribs.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 : " + fromserver + "/" + fromldif);
}
}
con.disconnect();
}
示例11: testExternalWithInternalBase
import com.novell.ldap.LDAPEntry; //导入依赖的package包/类
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();
Assert.fail("Results came back");
}
} catch (LDAPException e) {
if (e.getResultCode() != 32) {
throw e;
}
}
con.disconnect();
}
示例12: testAddAnonFail
import com.novell.ldap.LDAPEntry; //导入依赖的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();
}
示例13: testAddBoundSucceed
import com.novell.ldap.LDAPEntry; //导入依赖的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();
}
示例14: postSearchEntry
import com.novell.ldap.LDAPEntry; //导入依赖的package包/类
public void postSearchEntry(PostSearchEntryInterceptorChain chain,
Entry entry, DistinguishedName base, Int scope, Filter filter,
ArrayList<Attribute> attributes, Bool typesOnly,
LDAPSearchConstraints constraints) throws LDAPException {
chain.nextPostSearchEntry(entry,base,scope,filter,attributes,typesOnly,constraints);
ArrayList<Attribute> origAttributes = (ArrayList<Attribute>) chain.getRequest().get(key);
attributes.clear();
attributes.addAll(origAttributes);
if (attributes.size() != 0 && ! attributes.contains(ALL_ATTRIBS)) {
LDAPAttributeSet newAttribs = new LDAPAttributeSet();
Iterator<Attribute> it = attributes.iterator();
while (it.hasNext()) {
LDAPAttribute attrib = entry.getEntry().getAttribute(it.next().getAttribute().getName());
if (attrib != null) {
newAttribs.add(attrib);
}
}
entry.setEntry(new LDAPEntry(entry.getEntry().getDN(),newAttribs));
}
}
示例15: testSearchNoAttribsFilter
import com.novell.ldap.LDAPEntry; //导入依赖的package包/类
@Test
public void testSearchNoAttribsFilter() throws Exception {
LDAPConnection con = new LDAPConnection();
con.connect("localhost", 50983);
Util util = new Util();
LDAPSearchResults res = con.search("dc=nam,dc=compinternal,dc=com",2,"(uid=aa*)",new String[] {"1.1"},false);
LDAPAttributeSet attribs = new LDAPAttributeSet();
attribs.add(new LDAPAttribute("uid","aalberts"));
attribs.add(new LDAPAttribute("objectClass","inetOrgPerson"));
/*
attribs.add(new LDAPAttribute("givenname","Al"));
attribs.add(new LDAPAttribute("sn","Alberts"));*/
LDAPEntry entry = new LDAPEntry("uid=aalberts,dc=nam,dc=compinternal,dc=com",attribs);
if (! res.hasMore()) {
fail("entries not returned");
return;
}
LDAPEntry fromServer = res.next();
if (! util.compareEntry(entry,fromServer)) {
fail("2nd entry failed : \n" + util.toLDIF(fromServer));
}
}