1 /*
2 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
82 attrs.put(uid);
83
84 DirContext ctx = null;
85 String[] bases = new String[] { (String) env.get("client"),
86 (String) env.get("vendor"), "Add" };
87 String baseDN = LDAPTestUtils.buildDN(bases, (String) env.get("root"));
88 String entryDN = "cn=Austin Powers," + baseDN;
89 String expect = ""; // relative name
90
91 try {
92 // connect to server
93 ctx = new InitialDirContext(env);
94
95 // add entry
96 ctx.createSubcontext(entryDN, attrs);
97
98 // specify base search
99 SearchControls constraints = new SearchControls();
100 constraints.setSearchScope(SearchControls.OBJECT_SCOPE);
101
102 NamingEnumeration results = ctx
103 .search(entryDN, "(objectclass=*)", constraints);
104
105 int found = LDAPTestUtils.checkResult(results, expect);
106
107 if (found != 1) {
108 throw new RuntimeException(
109 "Check result failed, expect found 1 but actual is "
110 + found);
111 }
112
113 } finally {
114 LDAPTestUtils.cleanupSubcontext(ctx, entryDN);
115 LDAPTestUtils.cleanup(ctx);
116 }
117 }
118 }
|
1 /*
2 * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
82 attrs.put(uid);
83
84 DirContext ctx = null;
85 String[] bases = new String[] { (String) env.get("client"),
86 (String) env.get("vendor"), "Add" };
87 String baseDN = LDAPTestUtils.buildDN(bases, (String) env.get("root"));
88 String entryDN = "cn=Austin Powers," + baseDN;
89 String expect = ""; // relative name
90
91 try {
92 // connect to server
93 ctx = new InitialDirContext(env);
94
95 // add entry
96 ctx.createSubcontext(entryDN, attrs);
97
98 // specify base search
99 SearchControls constraints = new SearchControls();
100 constraints.setSearchScope(SearchControls.OBJECT_SCOPE);
101
102 NamingEnumeration<?> results = ctx
103 .search(entryDN, "(objectclass=*)", constraints);
104
105 int found = LDAPTestUtils.checkResult(results, expect);
106
107 if (found != 1) {
108 throw new RuntimeException(
109 "Check result failed, expect found 1 but actual is "
110 + found);
111 }
112
113 } finally {
114 LDAPTestUtils.cleanupSubcontext(ctx, entryDN);
115 LDAPTestUtils.cleanup(ctx);
116 }
117 }
118 }
|