2 * Unix SMB/CIFS implementation.
4 * Test LDB attribute functions
6 * Copyright (C) Andrew Bartlet <abartlet@samba.org> 2008-2009
7 * Copyright (C) Matthieu Patou <mat@matws.net> 2009
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "lib/events/events.h"
26 #include <ldb_errors.h>
28 #include "param/param.h"
29 #include "lib/cmdline/cmdline.h"
30 #include "auth/credentials/credentials.h"
31 #include "libcli/ldap/ldap_client.h"
32 #include "torture/smbtorture.h"
33 #include "torture/ldap/proto.h"
35 bool torture_ldap_session_expiry(struct torture_context
*torture
)
37 const char *host
= torture_setting_string(torture
, "host", NULL
);
38 struct cli_credentials
*credentials
= samba_cmdline_get_creds();
39 struct ldb_context
*ldb
= NULL
;
40 const char *url
= NULL
;
43 struct ldb_dn
*rootdn
= NULL
;
44 struct ldb_result
*result
= NULL
;
48 * Further down we request a ticket lifetime of 4
49 * seconds. Give the server 10 seconds for this to kick in
51 const struct timeval endtime
= timeval_current_ofs(10, 0);
53 url
= talloc_asprintf(torture
, "ldap://%s/", host
);
55 torture
, url
!=NULL
, ret
, fail
, "talloc_asprintf failed");
57 cli_credentials_set_kerberos_state(credentials
,
58 CRED_USE_KERBEROS_REQUIRED
,
61 ok
= lpcfg_set_option(
62 torture
->lp_ctx
, "gensec_gssapi:requested_life_time=4");
64 torture
, ok
, ret
, fail
, "lpcfg_set_option failed");
66 ldb
= ldb_wrap_connect(
75 torture
, ldb
!=NULL
, ret
, fail
, "ldb_wrap_connect failed");
77 rootdn
= ldb_dn_new(ldb
, ldb
, NULL
);
79 torture
, rootdn
!=NULL
, ret
, fail
, "ldb_dn_new failed");
86 LDB_SCOPE_BASE
, /* scope */
88 "(objectclass=*)"); /* exp_fmt */
90 torture
, rc
==LDB_SUCCESS
, ret
, fail
, "1st ldb_search failed");
100 LDB_SCOPE_BASE
, /* scope */
102 "(objectclass=*)"); /* exp_fmt */
103 printf("ldb_search returned %s\n", ldb_strerror(rc
));
106 if (rc
!= LDB_SUCCESS
) {
109 } while (!timeval_expired(&endtime
));
113 rc
==LDB_ERR_PROTOCOL_ERROR
,
116 "expected LDB_ERR_PROTOCOL_ERROR after 4 seconds");