本文整理汇总了Java中com.novell.ldap.LDAPConnection.connect方法的典型用法代码示例。如果您正苦于以下问题:Java LDAPConnection.connect方法的具体用法?Java LDAPConnection.connect怎么用?Java LDAPConnection.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.novell.ldap.LDAPConnection
的用法示例。
在下文中一共展示了LDAPConnection.connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSearchUsersBound
import com.novell.ldap.LDAPConnection; //导入方法依赖的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();
}
示例2: testLinuxSudo
import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
@Test
public void testLinuxSudo() throws Exception {
LDAPConnection con = new LDAPConnection();
con.connect("localhost", 50983);
LDAPSearchResults res = con.search("o=mycompany,c=us", 2, "(objectClass=*)", new String[0], false);
String str = checkSearch(res,"fulldir.ldif");
if (str.length() > 0) {
fail(str);
}
res = con.search("cn=users,o=mycompany,c=us", 2, "(&(objectClass=posixAccount)(uidNumber=505))", new String[] {"uid", "userPassword", "uidNumber", "gidNumber", "cn", "homeDirectory", "loginShell", "gecos", "description", "objectClass"}, false);
str = checkSearch(res,"uidNumberSearch.ldif");
if (str.length() > 0) {
fail(str);
}
res = con.search("cn=users,o=mycompany,c=us", 2, "(&(objectClass=posixGroup)(cn=sudoers))", new String[] {"uniqueMember", "uid", "objectClass"}, false);
str = checkSearch(res,"sudoersSearch.ldif");
if (str.length() > 0) {
fail(str);
}
con.disconnect();
}
示例3: 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();
}
示例4: testSearchPickAttribs
import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
@Test
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();
}
示例5: testSearchMemberships
import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
public void testSearchMemberships() throws Exception {
LDAPConnection con = new LDAPConnection();
con.connect("localhost", 50983);
LDAPSearchResults res = con.search("ou=groups,dc=domain,dc=com", 2, "(&(objectClass=groupOfUniqueNames)(uniqueMember=uid=tuser2,ou=people,dc=domain,dc=com))", new String[] {"objectClass"}, false);
LDIFReader reader = new LDIFReader(new FileInputStream(System.getenv("PROJ_DIR") + "/test/EmbeddedGroups/membershipSearch.ldif"));
Util util = new Util();
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));
}
}
con.disconnect();
if (! found) {
fail("no entries returned");
}
}
示例6: testGetDynGroup
import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
@Test
public void testGetDynGroup() throws Exception {
LDAPConnection con = new LDAPConnection();
con.connect("localhost", 50983);
LDAPSearchResults res = con.search("ou=groups,dc=domain,dc=com", 2, "(cn=Sales)", new String[0], false);
LDIFReader reader = new LDIFReader(new FileInputStream(System.getenv("PROJ_DIR") + "/test/DynGroups/domainGroupSearch.ldif"));
Util util = new Util();
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));
}
}
con.disconnect();
if (! found) {
fail("no entries returned");
}
}
示例7: testInternal
import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
@Test
public void testInternal() throws Exception {
LDAPConnection con = new LDAPConnection();
con.connect("127.0.0.1", 50983);
LDAPSearchResults res = con.search("o=mycompany,c=us",2, "(|(cn=testrouting)([email protected]))", new String[]{}, false);
String chkRes = checkSearch(res, "internal-results.ldif");
if (! chkRes.isEmpty()) {
fail(chkRes);
}
con.disconnect();
}
示例8: testAdminBind
import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
@Test
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();
}
示例9: testInternalWithOrMailNoRoute
import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
@Test
public void testInternalWithOrMailNoRoute() throws Exception {
LDAPConnection con = new LDAPConnection();
con.connect("127.0.0.1", 50983);
LDAPSearchResults res = con.search("ou=internal,o=mycompany,c=us",2, "(|(uid=internaluser)(mail=internaluser))", new String[]{}, false);
String chkRes = checkSearch(res, "internal-results.ldif");
if (! chkRes.isEmpty()) {
fail(chkRes);
}
con.disconnect();
}
示例10: testGetEmbGroup
import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
@Test
public void testGetEmbGroup() throws Exception {
LDAPConnection con = new LDAPConnection();
con.connect("localhost", 50983);
LDAPSearchResults res = con.search("ou=groups,dc=domain,dc=com", 2, "(cn=North East)", new String[0], false);
LDIFReader reader = new LDIFReader(new FileInputStream(System.getenv("PROJ_DIR") + "/test/EmbeddedGroups/expandMembers.ldif"));
Util util = new Util();
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));
}
}
con.disconnect();
if (! found) {
fail("no entries returned");
}
}
示例11: testControl
import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
@Test
public void testControl() throws Exception {
LDAPConnection con = new LDAPConnection();
con.connect("127.0.0.1", 50983);
LDAPSearchResults res = con.search("o=mycompany,c=us",2, "(cn=testrouting)", new String[]{}, false);
String chkRes = checkSearch(res, "control-results.ldif");
if (! chkRes.isEmpty()) {
fail(chkRes);
}
con.disconnect();
}
示例12: testANDSearch
import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
@Test
public void testANDSearch() throws LDAPException {
LDAPConnection con = new LDAPConnection();
con.connect("localhost",50983);
Util util = new Util();
LDAPSearchResults res = con.search("dc=nam,dc=compinternal,dc=com",2,"(&(l=NY)(l=LA)(uid=aalberts))",new String[0],false);
LDAPAttributeSet attribs = new LDAPAttributeSet();
attribs.add(new LDAPAttribute("l","LA"));
attribs.getAttribute("l").addValue("NY");
attribs.add(new LDAPAttribute("objectClass","inetOrgPerson"));
attribs.add(new LDAPAttribute("uid","aalberts"));
attribs.add(new LDAPAttribute("empid","2"));
attribs.add(new LDAPAttribute("givenname","Al"));
attribs.add(new LDAPAttribute("sn","Alberts"));
attribs.add(new LDAPAttribute("cn","Al Alberts"));
LDAPEntry entry = new LDAPEntry("empid=2,dc=nam,dc=compinternal,dc=com",attribs);
if (! res.hasMore()) {
fail("entries not returned");
return;
}
if (! util.compareEntry(entry,res.next())) {
fail("1st entry failed");
}
if (res.hasMore()) {
fail("too many entries");
}
con.disconnect();
}
示例13: testSearchSynGroupDMember2
import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
public void testSearchSynGroupDMember2() throws Exception {
LDAPConnection con = new LDAPConnection();
con.connect("localhost", 50983);
LDAPSearchResults res = con.search("ou=groups,o=ad", 2, "(&(cn=Sales)(objectClass=groupOfUniqueNames)(uniqueMember=uid=tuser2,ou=people,o=ad))", new String[] {}, false);
LDIFReader reader = new LDIFReader(new FileInputStream(System.getenv("PROJ_DIR") + "/test/DynGroups/domainGroupSearch2.ldif"));
Util util = new Util();
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));
}
}
con.disconnect();
if (! found) {
fail("no entries returned");
}
}
示例14: testSearchSynGroupSMember
import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
@Test
public void testSearchSynGroupSMember() throws Exception {
LDAPConnection con = new LDAPConnection();
con.connect("localhost", 50983);
LDAPSearchResults res = con.search("ou=groups,dc=domain,dc=com", 2, "(&(cn=Sales)(objectClass=groupOfUniqueNames)(uniqueMember=uid=tuser4,ou=people,dc=domain,dc=com))", new String[] {}, false);
LDIFReader reader = new LDIFReader(new FileInputStream(System.getenv("PROJ_DIR") + "/test/DynGroups/domainGroupSearch.ldif"));
Util util = new Util();
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));
}
}
con.disconnect();
if (! found) {
fail("no entries returned");
}
}
示例15: testUidSearchOnlyUID
import com.novell.ldap.LDAPConnection; //导入方法依赖的package包/类
@Test
public void testUidSearchOnlyUID() throws LDAPException {
LDAPAttributeSet attribs = new LDAPAttributeSet();
attribs.add(new LDAPAttribute("objectClass", "inetOrgPerson"));
// attribs.getAttribute("objectClass").addValue("customPerson");
attribs.add(new LDAPAttribute("cn", "Test1 User"));
attribs.add(new LDAPAttribute("sn", "User"));
// attribs.add(new LDAPAttribute("testAttrib", "testVal"));
attribs.add(new LDAPAttribute("uid", "tuser001"));
attribs.add(new LDAPAttribute("userPassword", "secret"));
// attribs.add(new LDAPAttribute("globalTestAttrib","globalTestVal"));
LDAPEntry entry2 = new LDAPEntry("uid=tuser001,cn=users,dc=ad,dc=com", attribs);
LDAPConnection con = new LDAPConnection();
con.connect("localhost", 50983);
// con.bind(3,"cn=admin,o=mycompany","manager".getBytes());
LDAPSearchResults res = con.search("dc=ad,dc=com", 2, "(uid=tuser001)", new String[] { "uid" }, false);
int size = 0;
while (res.hasMore()) {
LDAPEntry fromDir = res.next();
LDAPEntry controlEntry = null;// control.get(fromDir.getEntry().getDN());
if (size == 0) {
controlEntry = entry2;
} else if (size == 1) {
controlEntry = null;
} else {
controlEntry = null;
}
if (controlEntry == null) {
fail("Entry " + fromDir.getDN() + " should not be returned");
return;
}
if (!Util.compareEntry(fromDir, controlEntry)) {
fail("The entry was not correct : " + fromDir.toString());
return;
}
size++;
}
if (size != 1) {
fail("Not the correct number of entries : " + size);
}
con.disconnect();
}