summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/auth/auth.i4
-rw-r--r--source4/auth/auth_wrap.c39
-rw-r--r--source4/auth/credentials/credentials.i4
-rw-r--r--source4/auth/credentials/credentials_wrap.c111
-rw-r--r--source4/dsdb/samdb/ldb_modules/tests/samba3sam.py1067
-rw-r--r--source4/lib/events/events.i2
-rw-r--r--source4/lib/events/events_wrap.c12
-rw-r--r--source4/lib/ldb/ldb.i43
-rw-r--r--source4/lib/ldb/ldb.py8
-rw-r--r--source4/lib/ldb/ldb_wrap.c518
-rwxr-xr-xsource4/lib/ldb/tests/python/api.py17
-rwxr-xr-xsource4/lib/ldb/tests/python/ldap.py1355
-rw-r--r--source4/lib/registry/registry.i14
-rw-r--r--source4/lib/registry/registry_wrap.c367
-rw-r--r--source4/lib/registry/tests/bindings.py8
-rw-r--r--source4/lib/talloc/talloc.i2
-rw-r--r--source4/lib/tdb/tdb.i16
-rw-r--r--source4/lib/tdb/tdb_wrap.c152
-rw-r--r--source4/libcli/security/security_wrap.c72
-rw-r--r--source4/libcli/util/errors.i6
-rw-r--r--source4/librpc/rpc/dcerpc.i14
-rw-r--r--source4/librpc/rpc/dcerpc.py1
-rw-r--r--source4/librpc/rpc/dcerpc_wrap.c332
-rw-r--r--source4/param/param.i2
-rw-r--r--source4/param/param_wrap.c48
-rw-r--r--source4/samba4-knownfail1
-rwxr-xr-xsource4/scripting/bin/samba3dump387
-rw-r--r--source4/scripting/bin/winreg.py93
-rw-r--r--source4/scripting/ejs/smbcalls_reg.c2
-rw-r--r--source4/scripting/python/misc_wrap.c73
-rw-r--r--source4/scripting/python/samba/__init__.py20
-rw-r--r--source4/scripting/python/samba/provision.py4
-rw-r--r--source4/scripting/python/samba/samba3.py224
-rw-r--r--source4/scripting/python/samba/tests/__init__.py1
-rw-r--r--source4/scripting/python/samba/tests/samba3.py57
-rw-r--r--source4/scripting/python/samba/upgrade.py16
-rwxr-xr-xsource4/selftest/samba4_tests.sh4
37 files changed, 3815 insertions, 1281 deletions
diff --git a/source4/auth/auth.i b/source4/auth/auth.i
index 5c6f06edef..b1743ef765 100644
--- a/source4/auth/auth.i
+++ b/source4/auth/auth.i
@@ -36,11 +36,11 @@
%import "../lib/talloc/talloc.i"
%import "../param/param.i"
-%typemap(default) struct auth_session_info * {
+%typemap(default,noblock=1) struct auth_session_info * {
$1 = system_session_anon(NULL, global_loadparm);
}
-%typemap(freearg) struct auth_session_info * {
+%typemap(freearg,noblock=1) struct auth_session_info * {
talloc_free($1);
}
diff --git a/source4/auth/auth_wrap.c b/source4/auth/auth_wrap.c
index b366689f8d..af1827adc9 100644
--- a/source4/auth/auth_wrap.c
+++ b/source4/auth/auth_wrap.c
@@ -2464,15 +2464,16 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags)
#define SWIGTYPE_p_loadparm_service swig_types[5]
#define SWIGTYPE_p_long_long swig_types[6]
#define SWIGTYPE_p_param_context swig_types[7]
-#define SWIGTYPE_p_param_section swig_types[8]
-#define SWIGTYPE_p_short swig_types[9]
-#define SWIGTYPE_p_signed_char swig_types[10]
-#define SWIGTYPE_p_unsigned_char swig_types[11]
-#define SWIGTYPE_p_unsigned_int swig_types[12]
-#define SWIGTYPE_p_unsigned_long_long swig_types[13]
-#define SWIGTYPE_p_unsigned_short swig_types[14]
-static swig_type_info *swig_types[16];
-static swig_module_info swig_module = {swig_types, 15, 0, 0, 0, 0};
+#define SWIGTYPE_p_param_opt swig_types[8]
+#define SWIGTYPE_p_param_section swig_types[9]
+#define SWIGTYPE_p_short swig_types[10]
+#define SWIGTYPE_p_signed_char swig_types[11]
+#define SWIGTYPE_p_unsigned_char swig_types[12]
+#define SWIGTYPE_p_unsigned_int swig_types[13]
+#define SWIGTYPE_p_unsigned_long_long swig_types[14]
+#define SWIGTYPE_p_unsigned_short swig_types[15]
+static swig_type_info *swig_types[17];
+static swig_module_info swig_module = {swig_types, 16, 0, 0, 0, 0};
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
@@ -2537,12 +2538,8 @@ SWIGINTERN PyObject *_wrap_system_session(PyObject *SWIGUNUSEDPARM(self), PyObje
(char *) "lp_ctx", NULL
};
- {
- arg2 = loadparm_init(NULL);
- }
- {
- arg1 = NULL;
- }
+ arg2 = loadparm_init(NULL);
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:system_session",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res2 = SWIG_ConvertPtr(obj0, &argp2,SWIGTYPE_p_loadparm_context, 0 | 0 );
@@ -2571,12 +2568,8 @@ SWIGINTERN PyObject *_wrap_system_session_anon(PyObject *SWIGUNUSEDPARM(self), P
(char *) "lp_ctx", NULL
};
- {
- arg2 = loadparm_init(NULL);
- }
- {
- arg1 = NULL;
- }
+ arg2 = loadparm_init(NULL);
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:system_session_anon",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res2 = SWIG_ConvertPtr(obj0, &argp2,SWIGTYPE_p_loadparm_context, 0 | 0 );
@@ -2610,6 +2603,7 @@ static swig_type_info _swigt__p_loadparm_context = {"_p_loadparm_context", "stru
static swig_type_info _swigt__p_loadparm_service = {"_p_loadparm_service", "struct loadparm_service *|loadparm_service *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_long_long = {"_p_long_long", "int_least64_t *|int_fast64_t *|int64_t *|long long *|intmax_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_param_context = {"_p_param_context", "struct param_context *|param *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_param_opt = {"_p_param_opt", "struct param_opt *|param_opt *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_param_section = {"_p_param_section", "struct param_section *|param_section *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_short = {"_p_short", "short *|int_least16_t *|int16_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_signed_char = {"_p_signed_char", "signed char *|int_least8_t *|int_fast8_t *|int8_t *", 0, 0, (void*)0, 0};
@@ -2627,6 +2621,7 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_loadparm_service,
&_swigt__p_long_long,
&_swigt__p_param_context,
+ &_swigt__p_param_opt,
&_swigt__p_param_section,
&_swigt__p_short,
&_swigt__p_signed_char,
@@ -2644,6 +2639,7 @@ static swig_cast_info _swigc__p_loadparm_context[] = { {&_swigt__p_loadparm_con
static swig_cast_info _swigc__p_loadparm_service[] = { {&_swigt__p_loadparm_service, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_long_long[] = { {&_swigt__p_long_long, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_param_context[] = { {&_swigt__p_param_context, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_param_opt[] = { {&_swigt__p_param_opt, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_param_section[] = { {&_swigt__p_param_section, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_short[] = { {&_swigt__p_short, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_signed_char[] = { {&_swigt__p_signed_char, 0, 0, 0},{0, 0, 0, 0}};
@@ -2661,6 +2657,7 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_loadparm_service,
_swigc__p_long_long,
_swigc__p_param_context,
+ _swigc__p_param_opt,
_swigc__p_param_section,
_swigc__p_short,
_swigc__p_signed_char,
diff --git a/source4/auth/credentials/credentials.i b/source4/auth/credentials/credentials.i
index 78660bc46c..b06c4ff6da 100644
--- a/source4/auth/credentials/credentials.i
+++ b/source4/auth/credentials/credentials.i
@@ -34,7 +34,7 @@ typedef struct cli_credentials cli_credentials;
%import "typemaps.i"
%import "param/param.i"
-%typemap(default) struct cli_credentials * {
+%typemap(default,noblock=1) struct cli_credentials * {
$1 = NULL;
}
@@ -42,7 +42,7 @@ typedef struct cli_credentials cli_credentials;
#include "librpc/gen_ndr/samr.h" /* for struct samr_Password */
%}
-%typemap(out) struct samr_Password * {
+%typemap(out,noblock=1) struct samr_Password * {
$result = PyString_FromStringAndSize($1->hash, 16);
}
diff --git a/source4/auth/credentials/credentials_wrap.c b/source4/auth/credentials/credentials_wrap.c
index f8bd32af03..0beaf85f42 100644
--- a/source4/auth/credentials/credentials_wrap.c
+++ b/source4/auth/credentials/credentials_wrap.c
@@ -2464,15 +2464,16 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags)
#define SWIGTYPE_p_loadparm_service swig_types[5]
#define SWIGTYPE_p_long_long swig_types[6]
#define SWIGTYPE_p_param_context swig_types[7]
-#define SWIGTYPE_p_param_section swig_types[8]
-#define SWIGTYPE_p_short swig_types[9]
-#define SWIGTYPE_p_signed_char swig_types[10]
-#define SWIGTYPE_p_unsigned_char swig_types[11]
-#define SWIGTYPE_p_unsigned_int swig_types[12]
-#define SWIGTYPE_p_unsigned_long_long swig_types[13]
-#define SWIGTYPE_p_unsigned_short swig_types[14]
-static swig_type_info *swig_types[16];
-static swig_module_info swig_module = {swig_types, 15, 0, 0, 0, 0};
+#define SWIGTYPE_p_param_opt swig_types[8]
+#define SWIGTYPE_p_param_section swig_types[9]
+#define SWIGTYPE_p_short swig_types[10]
+#define SWIGTYPE_p_signed_char swig_types[11]
+#define SWIGTYPE_p_unsigned_char swig_types[12]
+#define SWIGTYPE_p_unsigned_int swig_types[13]
+#define SWIGTYPE_p_unsigned_long_long swig_types[14]
+#define SWIGTYPE_p_unsigned_short swig_types[15]
+static swig_type_info *swig_types[17];
+static swig_module_info swig_module = {swig_types, 16, 0, 0, 0, 0};
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
@@ -2800,9 +2801,7 @@ SWIGINTERN PyObject *_wrap_Credentials_get_username(PyObject *SWIGUNUSEDPARM(sel
(char *) "self", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_get_username",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -2839,9 +2838,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_username(PyObject *SWIGUNUSEDPARM(sel
(char *) "self",(char *) "value",(char *)"arg3", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:Credentials_set_username",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -2885,9 +2882,7 @@ SWIGINTERN PyObject *_wrap_Credentials_get_password(PyObject *SWIGUNUSEDPARM(sel
(char *) "self", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_get_password",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -2924,9 +2919,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_password(PyObject *SWIGUNUSEDPARM(sel
(char *) "self",(char *) "val",(char *)"arg3", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:Credentials_set_password",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -2970,9 +2963,7 @@ SWIGINTERN PyObject *_wrap_Credentials_get_domain(PyObject *SWIGUNUSEDPARM(self)
(char *) "self", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_get_domain",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3009,9 +3000,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_domain(PyObject *SWIGUNUSEDPARM(self)
(char *) "self",(char *) "val",(char *)"arg3", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:Credentials_set_domain",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3055,9 +3044,7 @@ SWIGINTERN PyObject *_wrap_Credentials_get_realm(PyObject *SWIGUNUSEDPARM(self),
(char *) "self", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_get_realm",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3094,9 +3081,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_realm(PyObject *SWIGUNUSEDPARM(self),
(char *) "self",(char *) "val",(char *)"arg3", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:Credentials_set_realm",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3148,9 +3133,7 @@ SWIGINTERN PyObject *_wrap_Credentials_parse_string(PyObject *SWIGUNUSEDPARM(sel
(char *) "self",(char *) "text",(char *)"arg3", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:Credentials_parse_string",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3194,9 +3177,7 @@ SWIGINTERN PyObject *_wrap_Credentials_get_bind_dn(PyObject *SWIGUNUSEDPARM(self
(char *) "self", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_get_bind_dn",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3229,9 +3210,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_bind_dn(PyObject *SWIGUNUSEDPARM(self
(char *) "self",(char *) "bind_dn", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:Credentials_set_bind_dn",kwnames,&obj0,&obj1)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3268,9 +3247,7 @@ SWIGINTERN PyObject *_wrap_Credentials_get_workstation(PyObject *SWIGUNUSEDPARM(
(char *) "self", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_get_workstation",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3307,9 +3284,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_workstation(PyObject *SWIGUNUSEDPARM(
(char *) "self",(char *) "workstation",(char *) "obtained", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:Credentials_set_workstation",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3356,12 +3331,8 @@ SWIGINTERN PyObject *_wrap_Credentials_guess(PyObject *SWIGUNUSEDPARM(self), PyO
(char *) "self",(char *) "lp_ctx", NULL
};
- {
- arg1 = NULL;
- }
- {
- arg2 = loadparm_init(NULL);
- }
+ arg1 = NULL;
+ arg2 = loadparm_init(NULL);
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:Credentials_guess",kwnames,&obj0,&obj1)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3396,9 +3367,7 @@ SWIGINTERN PyObject *_wrap_Credentials_is_anonymous(PyObject *SWIGUNUSEDPARM(sel
(char *) "self", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_is_anonymous",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3427,12 +3396,8 @@ SWIGINTERN PyObject *_wrap_Credentials_get_nt_hash(PyObject *SWIGUNUSEDPARM(self
(char *) "self", NULL
};
- {
- arg1 = NULL;
- }
- {
- arg2 = NULL;
- }
+ arg1 = NULL;
+ arg2 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_get_nt_hash",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3442,9 +3407,7 @@ SWIGINTERN PyObject *_wrap_Credentials_get_nt_hash(PyObject *SWIGUNUSEDPARM(self
arg1 = (cli_credentials *)(argp1);
}
result = (struct samr_Password *)cli_credentials_get_nt_hash(arg1,arg2);
- {
- resultobj = PyString_FromStringAndSize(result->hash, 16);
- }
+ resultobj = PyString_FromStringAndSize(result->hash, 16);
return resultobj;
fail:
return NULL;
@@ -3462,9 +3425,7 @@ SWIGINTERN PyObject *_wrap_Credentials_authentication_requested(PyObject *SWIGUN
(char *) "self", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_authentication_requested",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3492,9 +3453,7 @@ SWIGINTERN PyObject *_wrap_Credentials_wrong_password(PyObject *SWIGUNUSEDPARM(s
(char *) "self", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_wrong_password",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3521,9 +3480,7 @@ SWIGINTERN PyObject *_wrap_delete_Credentials(PyObject *SWIGUNUSEDPARM(self), Py
(char *) "self", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:delete_Credentials",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, SWIG_POINTER_DISOWN | 0 );
@@ -3589,6 +3546,7 @@ static swig_type_info _swigt__p_loadparm_context = {"_p_loadparm_context", "stru
static swig_type_info _swigt__p_loadparm_service = {"_p_loadparm_service", "struct loadparm_service *|loadparm_service *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_long_long = {"_p_long_long", "int_least64_t *|int_fast64_t *|int64_t *|long long *|intmax_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_param_context = {"_p_param_context", "struct param_context *|param *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_param_opt = {"_p_param_opt", "struct param_opt *|param_opt *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_param_section = {"_p_param_section", "struct param_section *|param_section *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_short = {"_p_short", "short *|int_least16_t *|int16_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_signed_char = {"_p_signed_char", "signed char *|int_least8_t *|int_fast8_t *|int8_t *", 0, 0, (void*)0, 0};
@@ -3606,6 +3564,7 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_loadparm_service,
&_swigt__p_long_long,
&_swigt__p_param_context,
+ &_swigt__p_param_opt,
&_swigt__p_param_section,
&_swigt__p_short,
&_swigt__p_signed_char,
@@ -3623,6 +3582,7 @@ static swig_cast_info _swigc__p_loadparm_context[] = { {&_swigt__p_loadparm_con
static swig_cast_info _swigc__p_loadparm_service[] = { {&_swigt__p_loadparm_service, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_long_long[] = { {&_swigt__p_long_long, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_param_context[] = { {&_swigt__p_param_context, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_param_opt[] = { {&_swigt__p_param_opt, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_param_section[] = { {&_swigt__p_param_section, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_short[] = { {&_swigt__p_short, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_signed_char[] = { {&_swigt__p_signed_char, 0, 0, 0},{0, 0, 0, 0}};
@@ -3640,6 +3600,7 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_loadparm_service,
_swigc__p_long_long,
_swigc__p_param_context,
+ _swigc__p_param_opt,
_swigc__p_param_section,
_swigc__p_short,
_swigc__p_signed_char,
diff --git a/source4/dsdb/samdb/ldb_modules/tests/samba3sam.py b/source4/dsdb/samdb/ldb_modules/tests/samba3sam.py
new file mode 100644
index 0000000000..6a4935bf4d
--- /dev/null
+++ b/source4/dsdb/samdb/ldb_modules/tests/samba3sam.py
@@ -0,0 +1,1067 @@
+#!/usr/bin/python
+
+# Unix SMB/CIFS implementation.
+# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2005-2007
+# Copyright (C) Martin Kuehl <mkhl@samba.org> 2006
+#
+# This is a Python port of the original in testprogs/ejs/samba3sam.js
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+import os
+import sys
+import samba
+import ldb
+from samba import Ldb, substitute_var
+from samba.tests import LdbTestCase, TestCaseInTempDir
+
+datadir = sys.argv[2]
+
+class Samba3SamTestCase(TestCaseInTempDir):
+ def setup_data(self, obj, ldif):
+ self.assertTrue(ldif is not None)
+ obj.db.add_ldif(substitute_var(ldif, obj.substvars))
+
+ def setup_modules(self, ldb, s3, s4, ldif):
+ self.assertTrue(ldif is not None)
+ ldb.add_ldif(substitute_var(ldif, s4.substvars))
+
+ ldif = """
+dn: @MAP=samba3sam
+@FROM: """ + s4.substvars["BASEDN"] + """
+@TO: sambaDomainName=TESTS,""" + s3.substvars["BASEDN"] + """
+
+dn: @MODULES
+@LIST: rootdse,paged_results,server_sort,extended_dn,asq,samldb,password_hash,operational,objectguid,rdn_name,samba3sam,partition
+
+dn: @PARTITION
+partition: """ + s4.substvars["BASEDN"] + ":" + s4.url + """
+partition: """ + s3.substvars["BASEDN"] + ":" + s3.url + """
+replicateEntries: @SUBCLASSES
+replicateEntries: @ATTRIBUTES
+replicateEntries: @INDEXLIST
+"""
+ ldb.add_ldif(ldif)
+
+ def test_s3sam_search(self, ldb):
+ print "Looking up by non-mapped attribute"
+ msg = ldb.search(expression="(cn=Administrator)")
+ self.assertEquals(len(msg), 1)
+ self.assertEquals(msg[0]["cn"], "Administrator")
+
+ print "Looking up by mapped attribute"
+ msg = ldb.search(expression="(name=Backup Operators)")
+ self.assertEquals(len(msg), 1)
+ self.assertEquals(msg[0]["name"], "Backup Operators")
+
+ print "Looking up by old name of renamed attribute"
+ msg = ldb.search(expression="(displayName=Backup Operators)")
+ self.assertEquals(len(msg), 0)
+
+ print "Looking up mapped entry containing SID"
+ msg = ldb.search(expression="(cn=Replicator)")
+ self.assertEquals(len(msg), 1)
+ print msg[0].dn
+ self.assertEquals(str(msg[0].dn), "cn=Replicator,ou=Groups,dc=vernstok,dc=nl")
+ self.assertEquals(msg[0]["objectSid"], "S-1-5-21-4231626423-2410014848-2360679739-552")
+
+ print "Checking mapping of objectClass"
+ oc = set(msg[0]["objectClass"])
+ self.assertTrue(oc is not None)
+ for i in oc:
+ self.assertEquals(oc[i] == "posixGroup" or oc[i], "group")
+
+ print "Looking up by objectClass"
+ msg = ldb.search(expression="(|(objectClass=user)(cn=Administrator))")
+ self.assertEquals(len(msg), 2)
+ for i in range(len(msg)):
+ self.assertEquals((str(msg[i].dn), "unixName=Administrator,ou=Users,dc=vernstok,dc=nl") or
+ (str(msg[i].dn) == "unixName=nobody,ou=Users,dc=vernstok,dc=nl"))
+
+
+ def test_s3sam_modify(ldb, s3):
+ print "Adding a record that will be fallbacked"
+ ldb.add_ldif("""
+dn: cn=Foo
+foo: bar
+blah: Blie
+cn: Foo
+showInAdvancedViewOnly: TRUE
+ """)
+
+ print "Checking for existence of record (local)"
+ # TODO: This record must be searched in the local database, which is currently only supported for base searches
+ # msg = ldb.search(expression="(cn=Foo)", ['foo','blah','cn','showInAdvancedViewOnly')]
+ # TODO: Actually, this version should work as well but doesn't...
+ #
+ #
+ attrs = ['foo','blah','cn','showInAdvancedViewOnly']
+ msg = ldb.search(expression="(cn=Foo)", base="cn=Foo", scope=ldb.LDB_SCOPE_BASE, attrs=attrs)
+ self.assertEquals(len(msg), 1)
+ self.assertEquals(msg[0]["showInAdvancedViewOnly"], "TRUE")
+ self.assertEquals(msg[0]["foo"], "bar")
+ self.assertEquals(msg[0]["blah"], "Blie")
+
+ print "Adding record that will be mapped"
+ ldb.add_ldif("""
+dn: cn=Niemand,cn=Users,dc=vernstok,dc=nl
+objectClass: user
+unixName: bin
+sambaUnicodePwd: geheim
+cn: Niemand
+""")
+
+ print "Checking for existence of record (remote)"
+ msg = ldb.search(expression="(unixName=bin)", attrs=['unixName','cn','dn', 'sambaUnicodePwd'])
+ self.assertEquals(len(msg), 1)
+ self.assertEquals(msg[0]["cn"], "Niemand")
+ self.assertEquals(msg[0]["sambaUnicodePwd"], "geheim")
+
+ print "Checking for existence of record (local && remote)"
+ msg = ldb.search(expression="(&(unixName=bin)(sambaUnicodePwd=geheim))",
+ attrs=['unixName','cn','dn', 'sambaUnicodePwd'])
+ self.assertEquals(len(msg), 1) # TODO: should check with more records
+ self.assertEquals(msg[0]["cn"], "Niemand")
+ self.assertEquals(msg[0]["unixName"], "bin")
+ self.assertEquals(msg[0]["sambaUnicodePwd"], "geheim")
+
+ print "Checking for existence of record (local || remote)"
+ msg = ldb.search(expression="(|(unixName=bin)(sambaUnicodePwd=geheim))",
+ attrs=['unixName','cn','dn', 'sambaUnicodePwd'])
+ print "got " + len(msg) + " replies"
+ self.assertEquals(len(msg), 1) # TODO: should check with more records
+ self.assertEquals(msg[0]["cn"], "Niemand")
+ self.assertEquals(msg[0]["unixName"] == "bin" or msg[0]["sambaUnicodePwd"], "geheim")
+
+ print "Checking for data in destination database"
+ msg = s3.db.search("(cn=Niemand)")
+ self.assertTrue(len(msg) >= 1)
+ self.assertEquals(msg[0]["sambaSID"], "S-1-5-21-4231626423-2410014848-2360679739-2001")
+ self.assertEquals(msg[0]["displayName"], "Niemand")
+
+ print "Adding attribute..."
+ ldb.modify_ldif("""
+dn: cn=Niemand,cn=Users,dc=vernstok,dc=nl
+changetype: modify
+add: description
+description: Blah
+""")
+
+ print "Checking whether changes are still there..."
+ msg = ldb.search(expression="(cn=Niemand)")
+ self.assertTrue(len(msg) >= 1)
+ self.assertEquals(msg[0]["cn"], "Niemand")
+ self.assertEquals(msg[0]["description"], "Blah")
+
+ print "Modifying attribute..."
+ ldb.modify_ldif("""
+dn: cn=Niemand,cn=Users,dc=vernstok,dc=nl
+changetype: modify
+replace: description
+description: Blie
+""")
+
+ print "Checking whether changes are still there..."
+ msg = ldb.search(expression="(cn=Niemand)")
+ self.assertTrue(len(msg) >= 1)
+ self.assertEquals(msg[0]["description"], "Blie")
+
+ print "Deleting attribute..."
+ ldb.modify_ldif("""
+dn: cn=Niemand,cn=Users,dc=vernstok,dc=nl
+changetype: modify
+delete: description
+""")
+
+ print "Checking whether changes are no longer there..."
+ msg = ldb.search(expression="(cn=Niemand)")
+ self.assertTrue(len(msg) >= 1)
+ self.assertEquals(msg[0]["description"], undefined)
+
+ print "Renaming record..."
+ ldb.rename("cn=Niemand,cn=Users,dc=vernstok,dc=nl", "cn=Niemand2,cn=Users,dc=vernstok,dc=nl")
+
+ print "Checking whether DN has changed..."
+ msg = ldb.search(expression="(cn=Niemand2)")
+ self.assertEquals(len(msg), 1)
+ self.assertEquals(str(msg[0].dn), "cn=Niemand2,cn=Users,dc=vernstok,dc=nl")
+
+ print "Deleting record..."
+ ldb.delete("cn=Niemand2,cn=Users,dc=vernstok,dc=nl")
+
+ print "Checking whether record is gone..."
+ msg = ldb.search(expression="(cn=Niemand2)")
+ self.assertEquals(len(msg), 0)
+
+ def test_map_search(ldb, s3, s4):
+ print "Running search tests on mapped data"
+ ldif = """
+dn: """ + "sambaDomainName=TESTS,""" + s3.substvars["BASEDN"] + """
+objectclass: sambaDomain
+objectclass: top
+sambaSID: S-1-5-21-4231626423-2410014848-2360679739
+sambaNextRid: 2000
+sambaDomainName: TESTS"""
+ self.assertTrue(ldif is not None)
+ s3.db.add_ldif(substitute_var(ldif, s3.substvars))
+
+ print "Add a set of split records"
+ ldif = """
+dn: """ + s4.dn("cn=X") + """
+objectClass: user
+cn: X
+codePage: x
+revision: x
+dnsHostName: x
+nextRid: y
+lastLogon: x
+description: x
+objectSid: S-1-5-21-4231626423-2410014848-2360679739-552
+primaryGroupID: 1-5-21-4231626423-2410014848-2360679739-512
+
+dn: """ + s4.dn("cn=Y") + """
+objectClass: top
+cn: Y
+codePage: x
+revision: x
+dnsHostName: y
+nextRid: y
+lastLogon: y
+description: x
+
+dn: """ + s4.dn("cn=Z") + """
+objectClass: top
+cn: Z
+codePage: x
+revision: y
+dnsHostName: z
+nextRid: y
+lastLogon: z
+description: y
+"""
+
+ self.assertTrue(ldif is not None)
+ ldb.add_ldif(substitute_var(ldif, s4.substvars))
+
+ print "Add a set of remote records"
+
+ ldif = """
+dn: """ + s3.dn("cn=A") + """
+objectClass: posixAccount
+cn: A
+sambaNextRid: x
+sambaBadPasswordCount: x
+sambaLogonTime: x
+description: x
+sambaSID: S-1-5-21-4231626423-2410014848-2360679739-552
+sambaPrimaryGroupSID: S-1-5-21-4231626423-2410014848-2360679739-512
+
+dn: """ + s3.dn("cn=B") + """
+objectClass: top
+cn:B
+sambaNextRid: x
+sambaBadPasswordCount: x
+sambaLogonTime: y
+description: x
+
+dn: """ + s3.dn("cn=C") + """
+objectClass: top
+cn: C
+sambaNextRid: x
+sambaBadPasswordCount: y
+sambaLogonTime: z
+description: y
+"""
+ self.assertTrue(ldif is not None)
+ s3.add_ldif(substitute_var(ldif, s3.substvars))
+
+ print "Testing search by DN"
+
+ # Search remote record by local DN
+ dn = s4.dn("cn=A")
+ attrs = ["dnsHostName", "lastLogon"]
+ res = ldb.search(dn, scope=ldb.SCOPE_BASE, attrs=attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(str(res[0].dn)), dn)
+ self.assertEquals(res[0]["dnsHostName"], undefined)
+ self.assertEquals(res[0]["lastLogon"], "x")
+
+ # Search remote record by remote DN
+ dn = s3.dn("cn=A")
+ attrs = ["dnsHostName", "lastLogon", "sambaLogonTime"]
+ res = s3.db.search(dn, scope=ldb.SCOPE_BASE, attrs=attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(str(res[0].dn)), dn)
+ self.assertEquals(res[0]["dnsHostName"], undefined)
+ self.assertEquals(res[0]["lastLogon"], undefined)
+ self.assertEquals(res[0]["sambaLogonTime"], "x")
+
+ # Search split record by local DN
+ dn = s4.dn("cn=X")
+ attrs = ["dnsHostName", "lastLogon"]
+ res = ldb.search(dn, scope=ldb.SCOPE_BASE, attrs=attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(str(res[0].dn)), dn)
+ self.assertEquals(res[0]["dnsHostName"], "x")
+ self.assertEquals(res[0]["lastLogon"], "x")
+
+ # Search split record by remote DN
+ dn = s3.dn("cn=X")
+ attrs = ["dnsHostName", "lastLogon", "sambaLogonTime"]
+ res = s3.db.search(dn, scope=ldb.SCOPE_BASE, attrs=attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(str(res[0].dn)), dn)
+ self.assertEquals(res[0]["dnsHostName"], undefined)
+ self.assertEquals(res[0]["lastLogon"], undefined)
+ self.assertEquals(res[0]["sambaLogonTime"], "x")
+
+ print "Testing search by attribute"
+
+ # Search by ignored attribute
+ attrs = ["dnsHostName", "lastLogon"]
+ res = ldb.search(expression="(revision=x)", scope=ldb.SCOPE_DEFAULT, attrs=attrs)
+ self.assertEquals(len(res), 2)
+ self.assertEquals(str(str(res[0].dn)), s4.dn("cn=Y"))
+ self.assertEquals(res[0]["dnsHostName"], "y")
+ self.assertEquals(res[0]["lastLogon"], "y")
+ self.assertEquals(str(str(res[1].dn)), s4.dn("cn=X"))
+ self.assertEquals(res[1]["dnsHostName"], "x")
+ self.assertEquals(res[1]["lastLogon"], "x")
+
+ # Search by kept attribute
+ attrs = ["dnsHostName", "lastLogon"]
+ res = ldb.search(expression="(description=y)", scope=ldb.SCOPE_DEFAULT, attrs=attrs)
+ self.assertEquals(len(res), 2)
+ self.assertEquals(str(str(res[0].dn)), s4.dn("cn=Z"))
+ self.assertEquals(res[0]["dnsHostName"], "z")
+ self.assertEquals(res[0]["lastLogon"], "z")
+ self.assertEquals(str(str(res[1].dn)), s4.dn("cn=C"))
+ self.assertEquals(res[1]["dnsHostName"], undefined)
+ self.assertEquals(res[1]["lastLogon"], "z")
+
+ # Search by renamed attribute
+ attrs = ["dnsHostName", "lastLogon"]
+ res = ldb.search(expression="(badPwdCount=x)", scope=ldb.SCOPE_DEFAULT, attrs=attrs)
+ self.assertEquals(len(res), 2)
+ self.assertEquals(str(res[0].dn), s4.dn("cn=B"))
+ self.assertEquals(res[0]["dnsHostName"], undefined)
+ self.assertEquals(res[0]["lastLogon"], "y")
+ self.assertEquals(str(res[1].dn), s4.dn("cn=A"))
+ self.assertEquals(res[1]["dnsHostName"], undefined)
+ self.assertEquals(res[1]["lastLogon"], "x")
+
+ # Search by converted attribute
+ attrs = ["dnsHostName", "lastLogon", "objectSid"]
+ # TODO:
+ # Using the SID directly in the parse tree leads to conversion
+ # errors, letting the search fail with no results.
+ #res = ldb.search("(objectSid=S-1-5-21-4231626423-2410014848-2360679739-552)", NULL, ldb. SCOPE_DEFAULT, attrs)
+ res = ldb.search(expression="(objectSid=*)", attrs=attrs)
+ self.assertEquals(len(res), 3)
+ self.assertEquals(str(res[0].dn), s4.dn("cn=X"))
+ self.assertEquals(res[0]["dnsHostName"], "x")
+ self.assertEquals(res[0]["lastLogon"], "x")
+ self.assertEquals(res[0]["objectSid"], "S-1-5-21-4231626423-2410014848-2360679739-552")
+ self.assertEquals(str(res[1].dn), s4.dn("cn=A"))
+ self.assertEquals(res[1]["dnsHostName"], undefined)
+ self.assertEquals(res[1]["lastLogon"], "x")
+ self.assertEquals(res[1]["objectSid"], "S-1-5-21-4231626423-2410014848-2360679739-552")
+
+ # Search by generated attribute
+ # In most cases, this even works when the mapping is missing
+ # a `convert_operator' by enumerating the remote db.
+ attrs = ["dnsHostName", "lastLogon", "primaryGroupID"]
+ res = ldb.search(expression="(primaryGroupID=512)", attrs=attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), s4.dn("cn=A"))
+ self.assertEquals(res[0]["dnsHostName"], undefined)
+ self.assertEquals(res[0]["lastLogon"], "x")
+ self.assertEquals(res[0]["primaryGroupID"], "512")
+
+ # TODO: There should actually be two results, A and X. The
+ # primaryGroupID of X seems to get corrupted somewhere, and the
+ # objectSid isn't available during the generation of remote (!) data,
+ # which can be observed with the following search. Also note that Xs
+ # objectSid seems to be fine in the previous search for objectSid... */
+ #res = ldb.search(expression="(primaryGroupID=*)", NULL, ldb. SCOPE_DEFAULT, attrs)
+ #print len(res) + " results found"
+ #for i in range(len(res)):
+ # for (obj in res[i]) {
+ # print obj + ": " + res[i][obj]
+ # }
+ # print "---"
+ #
+
+ # Search by remote name of renamed attribute */
+ attrs = ["dnsHostName", "lastLogon"]
+ res = ldb.search(expression="(sambaBadPasswordCount=*)", attrs=attrs)
+ self.assertEquals(len(res), 0)
+
+ # Search by objectClass
+ attrs = ["dnsHostName", "lastLogon", "objectClass"]
+ res = ldb.search(expression="(objectClass=user)", attrs=attrs)
+ self.assertEquals(len(res), 2)
+ self.assertEquals(str(res[0].dn), s4.dn("cn=X"))
+ self.assertEquals(res[0]["dnsHostName"], "x")
+ self.assertEquals(res[0]["lastLogon"], "x")
+ self.assertTrue(res[0]["objectClass"] is not None)
+ self.assertEquals(res[0]["objectClass"][0], "user")
+ self.assertEquals(str(res[1].dn), s4.dn("cn=A"))
+ self.assertEquals(res[1]["dnsHostName"], undefined)
+ self.assertEquals(res[1]["lastLogon"], "x")
+ self.assertTrue(res[1]["objectClass"] is not None)
+ self.assertEquals(res[1]["objectClass"][0], "user")
+
+ # Prove that the objectClass is actually used for the search
+ res = ldb.search(expression="(|(objectClass=user)(badPwdCount=x))", attrs=attrs)
+ self.assertEquals(len(res), 3)
+ self.assertEquals(str(res[0].dn), s4.dn("cn=B"))
+ self.assertEquals(res[0]["dnsHostName"], undefined)
+ self.assertEquals(res[0]["lastLogon"], "y")
+ self.assertTrue(res[0]["objectClass"] is not None)
+ for oc in set(res[0]["objectClass"]):
+ self.assertEquals(oc, "user")
+ self.assertEquals(str(res[1].dn), s4.dn("cn=X"))
+ self.assertEquals(res[1]["dnsHostName"], "x")
+ self.assertEquals(res[1]["lastLogon"], "x")
+ self.assertTrue(res[1]["objectClass"] is not None)
+ self.assertEquals(res[1]["objectClass"][0], "user")
+ self.assertEquals(str(res[2].dn), s4.dn("cn=A"))
+ self.assertEquals(res[2]["dnsHostName"], undefined)
+ self.assertEquals(res[2]["lastLogon"], "x")
+ self.assertTrue(res[2]["objectClass"] is not None)
+ self.assertEquals(res[2]["objectClass"][0], "user")
+
+ print "Testing search by parse tree"
+
+ # Search by conjunction of local attributes
+ attrs = ["dnsHostName", "lastLogon"]
+ res = ldb.search(expression="(&(codePage=x)(revision=x))", attrs=attrs)
+ self.assertEquals(len(res), 2)
+ self.assertEquals(str(res[0].dn), s4.dn("cn=Y"))
+ self.assertEquals(res[0]["dnsHostName"], "y")
+ self.assertEquals(res[0]["lastLogon"], "y")
+ self.assertEquals(str(res[1].dn), s4.dn("cn=X"))
+ self.assertEquals(res[1]["dnsHostName"], "x")
+ self.assertEquals(res[1]["lastLogon"], "x")
+
+ # Search by conjunction of remote attributes
+ attrs = ["dnsHostName", "lastLogon"]
+ res = ldb.search(expression="(&(lastLogon=x)(description=x))", attrs=attrs)
+ self.assertEquals(len(res), 2)
+ self.assertEquals(str(res[0].dn), s4.dn("cn=X"))
+ self.assertEquals(res[0]["dnsHostName"], "x")
+ self.assertEquals(res[0]["lastLogon"], "x")
+ self.assertEquals(str(res[1].dn), s4.dn("cn=A"))
+ self.assertEquals(res[1]["dnsHostName"], undefined)
+ self.assertEquals(res[1]["lastLogon"], "x")
+
+ # Search by conjunction of local and remote attribute
+ attrs = ["dnsHostName", "lastLogon"]
+ res = ldb.search(expression="(&(codePage=x)(description=x))", attrs=attrs)
+ self.assertEquals(len(res), 2)
+ self.assertEquals(str(res[0].dn), s4.dn("cn=Y"))
+ self.assertEquals(res[0]["dnsHostName"], "y")
+ self.assertEquals(res[0]["lastLogon"], "y")
+ self.assertEquals(str(res[1].dn), s4.dn("cn=X"))
+ self.assertEquals(res[1]["dnsHostName"], "x")
+ self.assertEquals(res[1]["lastLogon"], "x")
+
+ # Search by conjunction of local and remote attribute w/o match
+ attrs = ["dnsHostName", "lastLogon"]
+ res = ldb.search(expression="(&(codePage=x)(nextRid=x))", attrs=attrs)
+ self.assertEquals(len(res), 0)
+ res = ldb.search(expression="(&(revision=x)(lastLogon=z))", attrs=attrs)
+ self.assertEquals(len(res), 0)
+
+ # Search by disjunction of local attributes
+ attrs = ["dnsHostName", "lastLogon"]
+ res = ldb.search(expression="(|(revision=x)(dnsHostName=x))", attrs=attrs)
+ self.assertEquals(len(res), 2)
+ self.assertEquals(str(res[0].dn), s4.dn("cn=Y"))
+ self.assertEquals(res[0]["dnsHostName"], "y")
+ self.assertEquals(res[0]["lastLogon"], "y")
+ self.assertEquals(str(res[1].dn), s4.dn("cn=X"))
+ self.assertEquals(res[1]["dnsHostName"], "x")
+ self.assertEquals(res[1]["lastLogon"], "x")
+
+ # Search by disjunction of remote attributes
+ attrs = ["dnsHostName", "lastLogon"]
+ res = ldb.search(expression="(|(badPwdCount=x)(lastLogon=x))", attrs=attrs)
+ self.assertEquals(len(res), 3)
+ self.assertEquals(str(res[0].dn), s4.dn("cn=B"))
+ self.assertEquals(res[0]["dnsHostName"], undefined)
+ self.assertEquals(res[0]["lastLogon"], "y")
+ self.assertEquals(str(res[1].dn), s4.dn("cn=X"))
+ self.assertEquals(res[1]["dnsHostName"], "x")
+ self.assertEquals(res[1]["lastLogon"], "x")
+ self.assertEquals(str(res[2].dn), s4.dn("cn=A"))
+ self.assertEquals(res[2]["dnsHostName"], undefined)
+ self.assertEquals(res[2]["lastLogon"], "x")
+
+ # Search by disjunction of local and remote attribute
+ attrs = ["dnsHostName", "lastLogon"]
+ res = ldb.search(expression="(|(revision=x)(lastLogon=y))", attrs=attrs)
+ self.assertEquals(len(res), 3)
+ self.assertEquals(str(res[0].dn), s4.dn("cn=Y"))
+ self.assertEquals(res[0]["dnsHostName"], "y")
+ self.assertEquals(res[0]["lastLogon"], "y")
+ self.assertEquals(str(res[1].dn), s4.dn("cn=B"))
+ self.assertEquals(res[1]["dnsHostName"], undefined)
+ self.assertEquals(res[1]["lastLogon"], "y")
+ self.assertEquals(str(res[2].dn), s4.dn("cn=X"))
+ self.assertEquals(res[2]["dnsHostName"], "x")
+ self.assertEquals(res[2]["lastLogon"], "x")
+
+ # Search by disjunction of local and remote attribute w/o match
+ attrs = ["dnsHostName", "lastLogon"]
+ res = ldb.search(expression="(|(codePage=y)(nextRid=z))", attrs=attrs)
+ self.assertEquals(len(res), 0)
+
+ # Search by negated local attribute
+ attrs = ["dnsHostName", "lastLogon"]
+ res = ldb.search(expression="(!(revision=x))", attrs=attrs)
+ self.assertEquals(len(res), 5)
+ self.assertEquals(str(res[0].dn), s4.dn("cn=B"))
+ self.assertEquals(res[0]["dnsHostName"], undefined)
+ self.assertEquals(res[0]["lastLogon"], "y")
+ self.assertEquals(str(res[1].dn), s4.dn("cn=A"))
+ self.assertEquals(res[1]["dnsHostName"], undefined)
+ self.assertEquals(res[1]["lastLogon"], "x")
+ self.assertEquals(str(res[2].dn), s4.dn("cn=Z"))
+ self.assertEquals(res[2]["dnsHostName"], "z")
+ self.assertEquals(res[2]["lastLogon"], "z")
+ self.assertEquals(str(res[3].dn), s4.dn("cn=C"))
+ self.assertEquals(res[3]["dnsHostName"], undefined)
+ self.assertEquals(res[3]["lastLogon"], "z")
+
+ # Search by negated remote attribute
+ attrs = ["dnsHostName", "lastLogon"]
+ res = ldb.search(expression="(!(description=x))", attrs=attrs)
+ self.assertEquals(len(res), 3)
+ self.assertEquals(str(res[0].dn), s4.dn("cn=Z"))
+ self.assertEquals(res[0]["dnsHostName"], "z")
+ self.assertEquals(res[0]["lastLogon"], "z")
+ self.assertEquals(str(res[1].dn), s4.dn("cn=C"))
+ self.assertEquals(res[1]["dnsHostName"], undefined)
+ self.assertEquals(res[1]["lastLogon"], "z")
+
+ # Search by negated conjunction of local attributes
+ attrs = ["dnsHostName", "lastLogon"]
+ res = ldb.search(expression="(!(&(codePage=x)(revision=x)))", attrs=attrs)
+ self.assertEquals(len(res), 5)
+ self.assertEquals(str(res[0].dn), s4.dn("cn=B"))
+ self.assertEquals(res[0]["dnsHostName"], undefined)
+ self.assertEquals(res[0]["lastLogon"], "y")
+ self.assertEquals(str(res[1].dn), s4.dn("cn=A"))
+ self.assertEquals(res[1]["dnsHostName"], undefined)
+ self.assertEquals(res[1]["lastLogon"], "x")
+ self.assertEquals(str(res[2].dn), s4.dn("cn=Z"))
+ self.assertEquals(res[2]["dnsHostName"], "z")
+ self.assertEquals(res[2]["lastLogon"], "z")
+ self.assertEquals(str(res[3].dn), s4.dn("cn=C"))
+ self.assertEquals(res[3]["dnsHostName"], undefined)
+ self.assertEquals(res[3]["lastLogon"], "z")
+
+ # Search by negated conjunction of remote attributes
+ attrs = ["dnsHostName", "lastLogon"]
+ res = ldb.search(expression="(!(&(lastLogon=x)(description=x)))", attrs=attrs)
+ self.assertEquals(len(res), 5)
+ self.assertEquals(str(res[0].dn), s4.dn("cn=Y"))
+ self.assertEquals(res[0]["dnsHostName"], "y")
+ self.assertEquals(res[0]["lastLogon"], "y")
+ self.assertEquals(str(res[1].dn), s4.dn("cn=B"))
+ self.assertEquals(res[1]["dnsHostName"], undefined)
+ self.assertEquals(res[1]["lastLogon"], "y")
+ self.assertEquals(str(res[2].dn), s4.dn("cn=Z"))
+ self.assertEquals(res[2]["dnsHostName"], "z")
+ self.assertEquals(res[2]["lastLogon"], "z")
+ self.assertEquals(str(res[3].dn), s4.dn("cn=C"))
+ self.assertEquals(res[3]["dnsHostName"], undefined)
+ self.assertEquals(res[3]["lastLogon"], "z")
+
+ # Search by negated conjunction of local and remote attribute
+ attrs = ["dnsHostName", "lastLogon"]
+ res = ldb.search(expression="(!(&(codePage=x)(description=x)))", attrs=attrs)
+ self.assertEquals(len(res), 5)
+ self.assertEquals(str(res[0].dn), s4.dn("cn=B"))
+ self.assertEquals(res[0]["dnsHostName"], undefined)
+ self.assertEquals(res[0]["lastLogon"], "y")
+ self.assertEquals(str(res[1].dn), s4.dn("cn=A"))
+ self.assertEquals(res[1]["dnsHostName"], undefined)
+ self.assertEquals(res[1]["lastLogon"], "x")
+ self.assertEquals(str(res[2].dn), s4.dn("cn=Z"))
+ self.assertEquals(res[2]["dnsHostName"], "z")
+ self.assertEquals(res[2]["lastLogon"], "z")
+ self.assertEquals(str(res[3].dn), s4.dn("cn=C"))
+ self.assertEquals(res[3]["dnsHostName"], undefined)
+ self.assertEquals(res[3]["lastLogon"], "z")
+
+ # Search by negated disjunction of local attributes
+ attrs = ["dnsHostName", "lastLogon"]
+ res = ldb.search(expression="(!(|(revision=x)(dnsHostName=x)))", attrs=attrs)
+ self.assertEquals(str(res[0].dn), s4.dn("cn=B"))
+ self.assertEquals(res[0]["dnsHostName"], undefined)
+ self.assertEquals(res[0]["lastLogon"], "y")
+ self.assertEquals(str(res[1].dn), s4.dn("cn=A"))
+ self.assertEquals(res[1]["dnsHostName"], undefined)
+ self.assertEquals(res[1]["lastLogon"], "x")
+ self.assertEquals(str(res[2].dn), s4.dn("cn=Z"))
+ self.assertEquals(res[2]["dnsHostName"], "z")
+ self.assertEquals(res[2]["lastLogon"], "z")
+ self.assertEquals(str(res[3].dn), s4.dn("cn=C"))
+ self.assertEquals(res[3]["dnsHostName"], undefined)
+ self.assertEquals(res[3]["lastLogon"], "z")
+
+ # Search by negated disjunction of remote attributes
+ attrs = ["dnsHostName", "lastLogon"]
+ res = ldb.search(expression="(!(|(badPwdCount=x)(lastLogon=x)))", attrs=attrs)
+ self.assertEquals(len(res), 4)
+ self.assertEquals(str(res[0].dn), s4.dn("cn=Y"))
+ self.assertEquals(res[0]["dnsHostName"], "y")
+ self.assertEquals(res[0]["lastLogon"], "y")
+ self.assertEquals(str(res[1].dn), s4.dn("cn=Z"))
+ self.assertEquals(res[1]["dnsHostName"], "z")
+ self.assertEquals(res[1]["lastLogon"], "z")
+ self.assertEquals(str(res[2].dn), s4.dn("cn=C"))
+ self.assertEquals(res[2]["dnsHostName"], undefined)
+ self.assertEquals(res[2]["lastLogon"], "z")
+
+ # Search by negated disjunction of local and remote attribute
+ attrs = ["dnsHostName", "lastLogon"]
+ res = ldb.search(expression="(!(|(revision=x)(lastLogon=y)))", attrs=attrs)
+ self.assertEquals(len(res), 4)
+ self.assertEquals(str(res[0].dn), s4.dn("cn=A"))
+ self.assertEquals(res[0]["dnsHostName"], undefined)
+ self.assertEquals(res[0]["lastLogon"], "x")
+ self.assertEquals(str(res[1].dn), s4.dn("cn=Z"))
+ self.assertEquals(res[1]["dnsHostName"], "z")
+ self.assertEquals(res[1]["lastLogon"], "z")
+ self.assertEquals(str(res[2].dn), s4.dn("cn=C"))
+ self.assertEquals(res[2]["dnsHostName"], undefined)
+ self.assertEquals(res[2]["lastLogon"], "z")
+
+ print "Search by complex parse tree"
+ attrs = ["dnsHostName", "lastLogon"]
+ res = ldb.search(expression="(|(&(revision=x)(dnsHostName=x))(!(&(description=x)(nextRid=y)))(badPwdCount=y))", attrs=attrs)
+ self.assertEquals(len(res), 6)
+ self.assertEquals(str(res[0].dn), s4.dn("cn=B"))
+ self.assertEquals(res[0]["dnsHostName"], undefined)
+ self.assertEquals(res[0]["lastLogon"], "y")
+ self.assertEquals(str(res[1].dn), s4.dn("cn=X"))
+ self.assertEquals(res[1]["dnsHostName"], "x")
+ self.assertEquals(res[1]["lastLogon"], "x")
+ self.assertEquals(str(res[2].dn), s4.dn("cn=A"))
+ self.assertEquals(res[2]["dnsHostName"], undefined)
+ self.assertEquals(res[2]["lastLogon"], "x")
+ self.assertEquals(str(res[3].dn), s4.dn("cn=Z"))
+ self.assertEquals(res[3]["dnsHostName"], "z")
+ self.assertEquals(res[3]["lastLogon"], "z")
+ self.assertEquals(str(res[4].dn), s4.dn("cn=C"))
+ self.assertEquals(res[4]["dnsHostName"], undefined)
+ self.assertEquals(res[4]["lastLogon"], "z")
+
+ # Clean up
+ dns = [s4.dn("cn=%s" % n) for n in ["A","B","C","X","Y","Z"]]
+ for dn in dns:
+ ldb.delete(dn)
+
+ def test_map_modify(self, ldb, s3, s4):
+ print "Running modification tests on mapped data"
+
+ print "Testing modification of local records"
+
+ # Add local record
+ dn = "cn=test,dc=idealx,dc=org"
+ ldif = """
+dn: """ + dn + """
+cn: test
+foo: bar
+revision: 1
+description: test
+"""
+ ldb.add_ldif(ldif)
+ # Check it's there
+ attrs = ["foo", "revision", "description"]
+ res = ldb.search(dn, scope=ldb.SCOPE_BASE, attrs=attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), dn)
+ self.assertEquals(res[0]["foo"], "bar")
+ self.assertEquals(res[0]["revision"], "1")
+ self.assertEquals(res[0]["description"], "test")
+ # Check it's not in the local db
+ res = s4.db.search("(cn=test)", NULL, ldb.SCOPE_DEFAULT, attrs)
+ self.assertEquals(len(res), 0)
+ # Check it's not in the remote db
+ res = s3.db.search("(cn=test)", NULL, ldb.SCOPE_DEFAULT, attrs)
+ self.assertEquals(len(res), 0)
+
+ # Modify local record
+ ldif = """
+dn: """ + dn + """
+replace: foo
+foo: baz
+replace: description
+description: foo
+"""
+ ldb.modify_ldif(ldif)
+ # Check in local db
+ res = ldb.search(dn, scope=ldb.SCOPE_BASE, attrs=attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), dn)
+ self.assertEquals(res[0]["foo"], "baz")
+ self.assertEquals(res[0]["revision"], "1")
+ self.assertEquals(res[0]["description"], "foo")
+
+ # Rename local record
+ dn2 = "cn=toast,dc=idealx,dc=org"
+ ldb.rename(dn, dn2)
+ # Check in local db
+ res = ldb.search(dn2, scope=ldb.SCOPE_BASE, attrs=attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), dn2)
+ self.assertEquals(res[0]["foo"], "baz")
+ self.assertEquals(res[0]["revision"], "1")
+ self.assertEquals(res[0]["description"], "foo")
+
+ # Delete local record
+ ldb.delete(dn2)
+ # Check it's gone
+ res = ldb.search(dn2, scope=ldb.SCOPE_BASE)
+ self.assertEquals(len(res), 0)
+
+ print "Testing modification of remote records"
+
+ # Add remote record
+ dn = s4.dn("cn=test")
+ dn2 = s3.dn("cn=test")
+ ldif = """
+dn: """ + dn2 + """
+cn: test
+description: foo
+sambaBadPasswordCount: 3
+sambaNextRid: 1001
+"""
+ s3.db.add_ldif(ldif)
+ # Check it's there
+ attrs = ["description", "sambaBadPasswordCount", "sambaNextRid"]
+ res = s3.db.search("", dn2, ldb.SCOPE_BASE, attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), dn2)
+ self.assertEquals(res[0]["description"], "foo")
+ self.assertEquals(res[0]["sambaBadPasswordCount"], "3")
+ self.assertEquals(res[0]["sambaNextRid"], "1001")
+ # Check in mapped db
+ attrs = ["description", "badPwdCount", "nextRid"]
+ res = ldb.search(dn, scope=ldb.SCOPE_BASE, attrs=attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), dn)
+ self.assertEquals(res[0]["description"], "foo")
+ self.assertEquals(res[0]["badPwdCount"], "3")
+ self.assertEquals(res[0]["nextRid"], "1001")
+ # Check in local db
+ res = s4.db.search("", dn, ldb.SCOPE_BASE, attrs)
+ self.assertEquals(len(res), 0)
+
+ # Modify remote data of remote record
+ ldif = """
+dn: """ + dn + """
+replace: description
+description: test
+replace: badPwdCount
+badPwdCount: 4
+"""
+ ldb.modify_ldif(ldif)
+ # Check in mapped db
+ attrs = ["description", "badPwdCount", "nextRid"]
+ res = ldb.search(dn, scope=ldb.SCOPE_BASE, attrs=attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), dn)
+ self.assertEquals(res[0]["description"], "test")
+ self.assertEquals(res[0]["badPwdCount"], "4")
+ self.assertEquals(res[0]["nextRid"], "1001")
+ # Check in remote db
+ attrs = ["description", "sambaBadPasswordCount", "sambaNextRid"]
+ res = s3.db.search("", dn2, ldb.SCOPE_BASE, attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), dn2)
+ self.assertEquals(res[0]["description"], "test")
+ self.assertEquals(res[0]["sambaBadPasswordCount"], "4")
+ self.assertEquals(res[0]["sambaNextRid"], "1001")
+
+ # Rename remote record
+ dn2 = s4.dn("cn=toast")
+ ldb.rename(dn, dn2)
+ # Check in mapped db
+ dn = dn2
+ attrs = ["description", "badPwdCount", "nextRid"]
+ res = ldb.search(dn, scope=ldb.SCOPE_BASE, attrs=attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), dn)
+ self.assertEquals(res[0]["description"], "test")
+ self.assertEquals(res[0]["badPwdCount"], "4")
+ self.assertEquals(res[0]["nextRid"], "1001")
+ # Check in remote db
+ dn2 = s3.dn("cn=toast")
+ attrs = ["description", "sambaBadPasswordCount", "sambaNextRid"]
+ res = s3.db.search("", dn2, ldb.SCOPE_BASE, attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), dn2)
+ self.assertEquals(res[0]["description"], "test")
+ self.assertEquals(res[0]["sambaBadPasswordCount"], "4")
+ self.assertEquals(res[0]["sambaNextRid"], "1001")
+
+ # Delete remote record
+ ldb.delete(dn)
+ # Check in mapped db
+ res = ldb.search(dn, scope=ldb.SCOPE_BASE)
+ self.assertEquals(len(res), 0)
+ # Check in remote db
+ res = s3.db.search("", dn2, ldb.SCOPE_BASE)
+ self.assertEquals(len(res), 0)
+
+ # Add remote record (same as before)
+ dn = s4.dn("cn=test")
+ dn2 = s3.dn("cn=test")
+ ldif = """
+dn: """ + dn2 + """
+cn: test
+description: foo
+sambaBadPasswordCount: 3
+sambaNextRid: 1001
+"""
+ s3.db.add_ldif(ldif)
+
+ # Modify local data of remote record
+ ldif = """
+dn: """ + dn + """
+add: revision
+revision: 1
+replace: description
+description: test
+"""
+ ldb.modify_ldif(ldif)
+ # Check in mapped db
+ attrs = ["revision", "description"]
+ res = ldb.search(dn, scope=ldb.SCOPE_BASE, attrs=attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), dn)
+ self.assertEquals(res[0]["description"], "test")
+ self.assertEquals(res[0]["revision"], "1")
+ # Check in remote db
+ res = s3.db.search("", dn2, ldb.SCOPE_BASE, attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), dn2)
+ self.assertEquals(res[0]["description"], "test")
+ self.assertEquals(res[0]["revision"], undefined)
+ # Check in local db
+ res = s4.db.search("", dn, ldb.SCOPE_BASE, attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), dn)
+ self.assertEquals(res[0]["description"], undefined)
+ self.assertEquals(res[0]["revision"], "1")
+
+ # Delete (newly) split record
+ ldb.delete(dn)
+
+ print "Testing modification of split records"
+
+ # Add split record
+ dn = s4.dn("cn=test")
+ dn2 = s3.dn("cn=test")
+ ldif = """
+dn: """ + dn + """
+cn: test
+description: foo
+badPwdCount: 3
+nextRid: 1001
+revision: 1
+"""
+ ldb.add_ldif(ldif)
+ # Check it's there
+ attrs = ["description", "badPwdCount", "nextRid", "revision"]
+ res = ldb.search(dn, scope=ldb.SCOPE_BASE, attrs=attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), dn)
+ self.assertEquals(res[0]["description"], "foo")
+ self.assertEquals(res[0]["badPwdCount"], "3")
+ self.assertEquals(res[0]["nextRid"], "1001")
+ self.assertEquals(res[0]["revision"], "1")
+ # Check in local db
+ res = s4.db.search("", dn, ldb.SCOPE_BASE, attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), dn)
+ self.assertEquals(res[0]["description"], undefined)
+ self.assertEquals(res[0]["badPwdCount"], undefined)
+ self.assertEquals(res[0]["nextRid"], undefined)
+ self.assertEquals(res[0]["revision"], "1")
+ # Check in remote db
+ attrs = ["description", "sambaBadPasswordCount", "sambaNextRid", "revision"]
+ res = s3.db.search("", dn2, ldb.SCOPE_BASE, attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), dn2)
+ self.assertEquals(res[0]["description"], "foo")
+ self.assertEquals(res[0]["sambaBadPasswordCount"], "3")
+ self.assertEquals(res[0]["sambaNextRid"], "1001")
+ self.assertEquals(res[0]["revision"], undefined)
+
+ # Modify of split record
+ ldif = """
+dn: """ + dn + """
+replace: description
+description: test
+replace: badPwdCount
+badPwdCount: 4
+replace: revision
+revision: 2
+"""
+ ldb.modify_ldif(ldif)
+ # Check in mapped db
+ attrs = ["description", "badPwdCount", "nextRid", "revision"]
+ res = ldb.search(dn, scope=ldb.SCOPE_BASE, attrs=attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), dn)
+ self.assertEquals(res[0]["description"], "test")
+ self.assertEquals(res[0]["badPwdCount"], "4")
+ self.assertEquals(res[0]["nextRid"], "1001")
+ self.assertEquals(res[0]["revision"], "2")
+ # Check in local db
+ res = s4.db.search("", dn, ldb.SCOPE_BASE, attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), dn)
+ self.assertEquals(res[0]["description"], undefined)
+ self.assertEquals(res[0]["badPwdCount"], undefined)
+ self.assertEquals(res[0]["nextRid"], undefined)
+ self.assertEquals(res[0]["revision"], "2")
+ # Check in remote db
+ attrs = ["description", "sambaBadPasswordCount", "sambaNextRid", "revision"]
+ res = s3.db.search("", dn2, ldb.SCOPE_BASE, attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), dn2)
+ self.assertEquals(res[0]["description"], "test")
+ self.assertEquals(res[0]["sambaBadPasswordCount"], "4")
+ self.assertEquals(res[0]["sambaNextRid"], "1001")
+ self.assertEquals(res[0]["revision"], undefined)
+
+ # Rename split record
+ dn2 = s4.dn("cn=toast")
+ ldb.rename(dn, dn2)
+ # Check in mapped db
+ dn = dn2
+ attrs = ["description", "badPwdCount", "nextRid", "revision"]
+ res = ldb.search(dn, scope=ldb.SCOPE_BASE, attrs=attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), dn)
+ self.assertEquals(res[0]["description"], "test")
+ self.assertEquals(res[0]["badPwdCount"], "4")
+ self.assertEquals(res[0]["nextRid"], "1001")
+ self.assertEquals(res[0]["revision"], "2")
+ # Check in local db
+ res = s4.db.search("", dn, ldb.SCOPE_BASE, attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), dn)
+ self.assertEquals(res[0]["description"], undefined)
+ self.assertEquals(res[0]["badPwdCount"], undefined)
+ self.assertEquals(res[0]["nextRid"], undefined)
+ self.assertEquals(res[0]["revision"], "2")
+ # Check in remote db
+ dn2 = s3.dn("cn=toast")
+ attrs = ["description", "sambaBadPasswordCount", "sambaNextRid", "revision"]
+ res = s3.db.search("", dn2, ldb.SCOPE_BASE, attrs)
+ self.assertEquals(len(res), 1)
+ self.assertEquals(str(res[0].dn), dn2)
+ self.assertEquals(res[0]["description"], "test")
+ self.assertEquals(res[0]["sambaBadPasswordCount"], "4")
+ self.assertEquals(res[0]["sambaNextRid"], "1001")
+ self.assertEquals(res[0]["revision"], undefined)
+
+ # Delete split record
+ ldb.delete(dn)
+ # Check in mapped db
+ res = ldb.search(dn, scope=ldb.SCOPE_BASE)
+ self.assertEquals(len(res), 0)
+ # Check in local db
+ res = s4.db.search("", dn, ldb.SCOPE_BASE)
+ self.assertEquals(len(res), 0)
+ # Check in remote db
+ res = s3.db.search("", dn2, ldb.SCOPE_BASE)
+ self.assertEquals(len(res), 0)
+
+ def setUp(self):
+ super(Samba3SamTestCase, self).setUp()
+
+ def make_dn(rdn):
+ return rdn + ",sambaDomainName=TESTS," + this.substvars["BASEDN"]
+
+ def make_s4dn(rdn):
+ return rdn + "," + this.substvars["BASEDN"]
+
+ ldb = Ldb()
+
+ ldbfile = os.path.join(self.tempdir, "test.ldb")
+ ldburl = "tdb://" + ldbfile
+
+ tempdir = self.tempdir
+
+ class Target:
+ def __init__(self, file, basedn, dn):
+ self.file = os.path.join(tempdir, file)
+ self.url = "tdb://" + self.file
+ self.substvars = {"BASEDN": basedn}
+ self.db = Ldb()
+ self.dn = dn
+
+ samba4 = Target("samba4.ldb", "dc=vernstok,dc=nl", make_s4dn)
+ samba3 = Target("samba3.ldb", "cn=Samba3Sam", make_dn)
+ templates = Target("templates.ldb", "cn=templates", None)
+
+ ldb.connect(ldburl)
+ samba3.db.connect(samba3.url)
+ templates.db.connect(templates.url)
+ samba4.db.connect(samba4.url)
+
+ self.setup_data(samba3, open(os.path.join(datadir, "samba3.ldif"), 'r').read())
+ self.setup_data(templates, open(os.path.join(datadir, "provision_samba3sam_templates.ldif"), 'r').read())
+ self.setup_modules(ldb, samba3, samba4, open(os.path.join(datadir, "provision_samba3sam.ldif"), 'r').read())
+
+ ldb = Ldb()
+ ldb.connect(ldburl)
+
+ self.test_s3sam_search(ldb)
+ self.test_s3sam_modify(ldb, samba3)
+
+ os.unlink(ldbfile)
+ os.unlink(samba3.file)
+ os.unlink(templates.file)
+ os.unlink(samba4.file)
+
+ ldb = Ldb()
+ ldb.connect(ldburl)
+ samba3.db = Ldb()
+ samba3.db.connect(samba3.url)
+ templates.db = Ldb()
+ templates.db.connect(templates.url)
+ samba4.db = Ldb()
+ samba4.db.connect(samba4.url)
+
+ self.setup_data(templates, open(os.path.join(datadir, "provision_samba3sam_templates.ldif"), 'r').read())
+ self.setup_modules(ldb, samba3, samba4, open(os.path.join(datadir, "provision_samba3sam.ldif"), 'r').read())
+
+ ldb = Ldb()
+ ldb.connect(ldburl)
+
+ test_map_search(ldb, samba3, samba4)
+ test_map_modify(ldb, samba3, samba4)
+
diff --git a/source4/lib/events/events.i b/source4/lib/events/events.i
index 925a74c252..e2f3b788cb 100644
--- a/source4/lib/events/events.i
+++ b/source4/lib/events/events.i
@@ -26,7 +26,7 @@
struct event_context *event_context_init(TALLOC_CTX *mem_ctx);
-%typemap(default) struct event_context * {
+%typemap(default,noblock=1) struct event_context * {
$1 = event_context_init(NULL);
}
diff --git a/source4/lib/events/events_wrap.c b/source4/lib/events/events_wrap.c
index 08158cdc63..c3eef44882 100644
--- a/source4/lib/events/events_wrap.c
+++ b/source4/lib/events/events_wrap.c
@@ -2579,9 +2579,7 @@ SWIGINTERN PyObject *_wrap_event_context_init(PyObject *SWIGUNUSEDPARM(self), Py
TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ;
struct event_context *result = 0 ;
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!SWIG_Python_UnpackTuple(args,"event_context_init",0,0,0)) SWIG_fail;
result = (struct event_context *)event_context_init(arg1);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_event_context, 0 | 0 );
@@ -2604,9 +2602,7 @@ SWIGINTERN PyObject *_wrap_event_context_init_byname(PyObject *SWIGUNUSEDPARM(se
(char *) "name", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:event_context_init_byname",kwnames,&obj0)) SWIG_fail;
res2 = SWIG_AsCharPtrAndSize(obj0, &buf2, NULL, &alloc2);
if (!SWIG_IsOK(res2)) {
@@ -2628,9 +2624,7 @@ SWIGINTERN PyObject *_wrap_event_backend_list(PyObject *SWIGUNUSEDPARM(self), Py
TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ;
char **result = 0 ;
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!SWIG_Python_UnpackTuple(args,"event_backend_list",0,0,0)) SWIG_fail;
result = (char **)event_backend_list(arg1);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_p_char, 0 | 0 );
diff --git a/source4/lib/ldb/ldb.i b/source4/lib/ldb/ldb.i
index 1ed1b45eaf..7c8241ba54 100644
--- a/source4/lib/ldb/ldb.i
+++ b/source4/lib/ldb/ldb.i
@@ -67,13 +67,13 @@ typedef int ldb_error;
/* The ldb functions will crash if a NULL ldb context is passed so
catch this before it happens. */
-%typemap(check) struct ldb_context* {
+%typemap(check,noblock=1) struct ldb_context* {
if ($1 == NULL)
SWIG_exception(SWIG_ValueError,
"ldb context must be non-NULL");
}
-%typemap(check) ldb_msg * {
+%typemap(check,noblock=1) ldb_msg * {
if ($1 == NULL)
SWIG_exception(SWIG_ValueError,
"Message can not be None");
@@ -83,7 +83,7 @@ typedef int ldb_error;
* Wrap struct ldb_val
*/
-%typemap(in) struct ldb_val *INPUT (struct ldb_val temp) {
+%typemap(in,noblock=1) struct ldb_val *INPUT (struct ldb_val temp) {
$1 = &temp;
if (!PyString_Check($input)) {
PyErr_SetString(PyExc_TypeError, "string arg expected");
@@ -93,7 +93,7 @@ typedef int ldb_error;
$1->data = PyString_AsString($input);
}
-%typemap(out) struct ldb_val {
+%typemap(out,noblock=1) struct ldb_val {
$result = PyString_FromStringAndSize((const char *)$1.data, $1.length);
}
@@ -101,7 +101,7 @@ typedef int ldb_error;
* Wrap struct ldb_result
*/
-%typemap(in, numinputs=0) struct ldb_result **OUT (struct ldb_result *temp_ldb_result) {
+%typemap(in,noblock=1,numinputs=0) struct ldb_result **OUT (struct ldb_result *temp_ldb_result) {
$1 = &temp_ldb_result;
}
@@ -115,7 +115,7 @@ typedef int ldb_error;
}
}
-%typemap(in, numinputs=1) const char * const *attrs {
+%typemap(in,noblock=1,numinputs=1) const char * const *attrs {
if ($input == Py_None) {
$1 = NULL;
} else if (PySequence_Check($input)) {
@@ -196,12 +196,16 @@ fail:
int ldb_dn_from_pyobject(TALLOC_CTX *mem_ctx, PyObject *object,
struct ldb_context *ldb, ldb_dn **dn)
{
+ int ret;
+ struct ldb_dn *odn;
if (ldb != NULL && PyString_Check(object)) {
*dn = ldb_dn_new(mem_ctx, ldb, PyString_AsString(object));
return 0;
}
- return SWIG_ConvertPtr(object, (void **)dn, SWIGTYPE_p_ldb_dn,
+ ret = SWIG_ConvertPtr(object, (void **)&odn, SWIGTYPE_p_ldb_dn,
SWIG_POINTER_EXCEPTION);
+ *dn = ldb_dn_copy(mem_ctx, odn);
+ return ret;
}
ldb_msg_element *ldb_msg_element_from_pyobject(PyObject *set_obj, int flags,
@@ -277,6 +281,15 @@ typedef struct ldb_message_element {
~ldb_msg_element() { talloc_free($self); }
int compare(ldb_msg_element *);
}
+ %pythoncode {
+ def __eq__(self, other):
+ if (isinstance(other, str) and
+ len(set(self)) == 1 and
+ set(self).pop() == other):
+ return True
+ return self.__cmp__(other) == 0
+
+ }
} ldb_msg_element;
/* ldb_message */
@@ -427,7 +440,7 @@ PyObject *PyExc_LdbError;
*/
-%typemap(out) ldb_error {
+%typemap(out,noblock=1) ldb_error {
if ($1 != LDB_SUCCESS) {
PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", $1, ldb_strerror($1)));
SWIG_fail;
@@ -436,6 +449,17 @@ PyObject *PyExc_LdbError;
};
%rename(Ldb) ldb_context;
+
+%typemap(in,noblock=1) struct ldb_dn * {
+ if (ldb_dn_from_pyobject(NULL, $input, arg1, &$1) != 0) {
+ SWIG_fail;
+ }
+};
+
+%typemap(freearg,noblock=1) struct ldb_dn * {
+ talloc_free($1);
+};
+
/* Top-level ldb operations */
typedef struct ldb_context {
%extend {
@@ -554,6 +578,9 @@ fail:
}
} ldb;
+%typemap(in,noblock=1) struct ldb_dn *;
+%typemap(freearg,noblock=1) struct ldb_dn *;
+
%nodefault ldb_message;
%nodefault ldb_context;
%nodefault Dn;
diff --git a/source4/lib/ldb/ldb.py b/source4/lib/ldb/ldb.py
index 63c6555c28..160fa88dff 100644
--- a/source4/lib/ldb/ldb.py
+++ b/source4/lib/ldb/ldb.py
@@ -94,6 +94,14 @@ class ldb_msg_element(object):
def __init__(self): raise AttributeError, "No constructor defined"
__repr__ = _swig_repr
__swig_destroy__ = _ldb.delete_ldb_msg_element
+ def __eq__(self, other):
+ if (isinstance(other, str) and
+ len(set(self)) == 1 and
+ set(self).pop() == other):
+ return True
+ return self.__cmp__(other) == 0
+
+
ldb_msg_element.__iter__ = new_instancemethod(_ldb.ldb_msg_element___iter__,None,ldb_msg_element)
ldb_msg_element.__set__ = new_instancemethod(_ldb.ldb_msg_element___set__,None,ldb_msg_element)
ldb_msg_element.__cmp__ = new_instancemethod(_ldb.ldb_msg_element___cmp__,None,ldb_msg_element)
diff --git a/source4/lib/ldb/ldb_wrap.c b/source4/lib/ldb/ldb_wrap.c
index 827fad09e1..1823fc192c 100644
--- a/source4/lib/ldb/ldb_wrap.c
+++ b/source4/lib/ldb/ldb_wrap.c
@@ -2675,12 +2675,16 @@ SWIGINTERN ldb_dn *ldb_dn___add__(ldb_dn *self,ldb_dn *other){
int ldb_dn_from_pyobject(TALLOC_CTX *mem_ctx, PyObject *object,
struct ldb_context *ldb, ldb_dn **dn)
{
+ int ret;
+ struct ldb_dn *odn;
if (ldb != NULL && PyString_Check(object)) {
*dn = ldb_dn_new(mem_ctx, ldb, PyString_AsString(object));
return 0;
}
- return SWIG_ConvertPtr(object, (void **)dn, SWIGTYPE_p_ldb_dn,
+ ret = SWIG_ConvertPtr(object, (void **)&odn, SWIGTYPE_p_ldb_dn,
SWIG_POINTER_EXCEPTION);
+ *dn = ldb_dn_copy(mem_ctx, odn);
+ return ret;
}
ldb_msg_element *ldb_msg_element_from_pyobject(PyObject *set_obj, int flags,
@@ -3137,11 +3141,9 @@ SWIGINTERN PyObject *_wrap_new_Dn(PyObject *SWIGUNUSEDPARM(self), PyObject *args
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_Dn" "', argument " "2"" of type '" "char const *""'");
}
arg2 = (char *)(buf2);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
result = (ldb_dn *)new_ldb_dn(arg1,(char const *)arg2);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_dn, SWIG_POINTER_NEW | 0 );
if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
@@ -3760,11 +3762,9 @@ SWIGINTERN PyObject *_wrap_ldb_msg_list_elements(PyObject *SWIGUNUSEDPARM(self),
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_msg_list_elements" "', argument " "1"" of type '" "ldb_msg *""'");
}
arg1 = (ldb_msg *)(argp1);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "Message can not be None");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "Message can not be None");
result = (PyObject *)ldb_msg_list_elements(arg1);
resultobj = result;
return resultobj;
@@ -3794,11 +3794,9 @@ SWIGINTERN PyObject *_wrap_Message_dn_set(PyObject *SWIGUNUSEDPARM(self), PyObje
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Message_dn_set" "', argument " "2"" of type '" "ldb_dn *""'");
}
arg2 = (ldb_dn *)(argp2);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "Message can not be None");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "Message can not be None");
if (arg1) (arg1)->dn = arg2;
resultobj = SWIG_Py_Void();
@@ -3823,11 +3821,9 @@ SWIGINTERN PyObject *_wrap_Message_dn_get(PyObject *SWIGUNUSEDPARM(self), PyObje
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Message_dn_get" "', argument " "1"" of type '" "ldb_msg *""'");
}
arg1 = (ldb_msg *)(argp1);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "Message can not be None");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "Message can not be None");
result = (ldb_dn *) ((arg1)->dn);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_dn, 0 | 0 );
return resultobj;
@@ -3877,11 +3873,9 @@ SWIGINTERN PyObject *_wrap_delete_Message(PyObject *SWIGUNUSEDPARM(self), PyObje
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Message" "', argument " "1"" of type '" "ldb_msg *""'");
}
arg1 = (ldb_msg *)(argp1);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "Message can not be None");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "Message can not be None");
delete_ldb_msg(arg1);
resultobj = SWIG_Py_Void();
@@ -3918,11 +3912,9 @@ SWIGINTERN PyObject *_wrap_Message___getitem__(PyObject *SWIGUNUSEDPARM(self), P
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Message___getitem__" "', argument " "2"" of type '" "char const *""'");
}
arg2 = (char *)(buf2);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "Message can not be None");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "Message can not be None");
result = (ldb_msg_element *)ldb_msg_find_element(arg1,(char const *)arg2);
{
if (result == NULL)
@@ -3967,11 +3959,9 @@ SWIGINTERN PyObject *_wrap_Message___setitem____SWIG_0(PyObject *SWIGUNUSEDPARM(
SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Message___setitem__" "', argument " "3"" of type '" "ldb_msg_element *""'");
}
arg3 = (ldb_msg_element *)(argp3);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "Message can not be None");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "Message can not be None");
ldb_msg___setitem____SWIG_0(arg1,(char const *)arg2,arg3);
resultobj = SWIG_Py_Void();
if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
@@ -4005,11 +3995,9 @@ SWIGINTERN PyObject *_wrap_Message___setitem____SWIG_1(PyObject *SWIGUNUSEDPARM(
}
arg2 = (char *)(buf2);
arg3 = swig_obj[2];
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "Message can not be None");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "Message can not be None");
ldb_msg___setitem____SWIG_1(arg1,(char const *)arg2,arg3);
resultobj = SWIG_Py_Void();
if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
@@ -4063,11 +4051,9 @@ SWIGINTERN PyObject *_wrap_Message___len__(PyObject *SWIGUNUSEDPARM(self), PyObj
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Message___len__" "', argument " "1"" of type '" "ldb_msg *""'");
}
arg1 = (ldb_msg *)(argp1);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "Message can not be None");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "Message can not be None");
result = (unsigned int)ldb_msg___len__(arg1);
resultobj = SWIG_From_unsigned_SS_int((unsigned int)(result));
return resultobj;
@@ -4091,11 +4077,9 @@ SWIGINTERN PyObject *_wrap_Message_keys(PyObject *SWIGUNUSEDPARM(self), PyObject
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Message_keys" "', argument " "1"" of type '" "ldb_msg *""'");
}
arg1 = (ldb_msg *)(argp1);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "Message can not be None");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "Message can not be None");
result = (PyObject *)ldb_msg_keys(arg1);
resultobj = result;
return resultobj;
@@ -4119,11 +4103,9 @@ SWIGINTERN PyObject *_wrap_Message___iter__(PyObject *SWIGUNUSEDPARM(self), PyOb
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Message___iter__" "', argument " "1"" of type '" "ldb_msg *""'");
}
arg1 = (ldb_msg *)(argp1);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "Message can not be None");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "Message can not be None");
result = (PyObject *)ldb_msg___iter__(arg1);
resultobj = result;
return resultobj;
@@ -4158,11 +4140,9 @@ SWIGINTERN PyObject *_wrap_Message___delitem__(PyObject *SWIGUNUSEDPARM(self), P
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Message___delitem__" "', argument " "2"" of type '" "char const *""'");
}
arg2 = (char *)(buf2);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "Message can not be None");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "Message can not be None");
ldb_msg_remove_attr(arg1,(char const *)arg2);
resultobj = SWIG_Py_Void();
if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
@@ -4310,19 +4290,15 @@ SWIGINTERN PyObject *_wrap_Ldb_connect(PyObject *SWIGUNUSEDPARM(self), PyObject
}
arg4 = (char **)(argp4);
}
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
result = ldb_connect(arg1,(char const *)arg2,arg3,(char const *(*))arg4);
- {
- if (result != 0) {
- PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
- SWIG_fail;
- }
- resultobj = Py_None;
+ if (result != 0) {
+ PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
+ SWIG_fail;
}
+ resultobj = Py_None;
if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
return resultobj;
fail:
@@ -4345,11 +4321,9 @@ SWIGINTERN PyObject *_wrap_delete_Ldb(PyObject *SWIGUNUSEDPARM(self), PyObject *
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Ldb" "', argument " "1"" of type '" "ldb *""'");
}
arg1 = (ldb *)(argp1);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
delete_ldb(arg1);
resultobj = SWIG_Py_Void();
@@ -4370,8 +4344,6 @@ SWIGINTERN PyObject *_wrap_Ldb_search(PyObject *SWIGUNUSEDPARM(self), PyObject *
ldb_error result;
void *argp1 = 0 ;
int res1 = 0 ;
- void *argp2 = 0 ;
- int res2 = 0 ;
int val3 ;
int ecode3 = 0 ;
int res4 ;
@@ -4388,9 +4360,7 @@ SWIGINTERN PyObject *_wrap_Ldb_search(PyObject *SWIGUNUSEDPARM(self), PyObject *
(char *) "self",(char *) "base",(char *) "scope",(char *) "expression",(char *) "attrs", NULL
};
- {
- arg6 = &temp_ldb_result6;
- }
+ arg6 = &temp_ldb_result6;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|OOOO:Ldb_search",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
@@ -4398,11 +4368,9 @@ SWIGINTERN PyObject *_wrap_Ldb_search(PyObject *SWIGUNUSEDPARM(self), PyObject *
}
arg1 = (ldb *)(argp1);
if (obj1) {
- res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_dn, 0 | 0 );
- if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Ldb_search" "', argument " "2"" of type '" "ldb_dn *""'");
+ if (ldb_dn_from_pyobject(NULL, obj1, arg1, &arg2) != 0) {
+ SWIG_fail;
}
- arg2 = (ldb_dn *)(argp2);
}
if (obj2) {
ecode3 = SWIG_AsVal_int(obj2, &val3);
@@ -4419,33 +4387,27 @@ SWIGINTERN PyObject *_wrap_Ldb_search(PyObject *SWIGUNUSEDPARM(self), PyObject *
arg4 = (char *)(buf4);
}
if (obj4) {
- {
- if (obj4 == Py_None) {
- arg5 = NULL;
- } else if (PySequence_Check(obj4)) {
- int i;
- arg5 = talloc_array(NULL, char *, PySequence_Size(obj4)+1);
- for(i = 0; i < PySequence_Size(obj4); i++)
- arg5[i] = PyString_AsString(PySequence_GetItem(obj4, i));
- arg5[i] = NULL;
- } else {
- SWIG_exception(SWIG_TypeError, "expected sequence");
- }
+ if (obj4 == Py_None) {
+ arg5 = NULL;
+ } else if (PySequence_Check(obj4)) {
+ int i;
+ arg5 = talloc_array(NULL, char *, PySequence_Size(obj4)+1);
+ for(i = 0; i < PySequence_Size(obj4); i++)
+ arg5[i] = PyString_AsString(PySequence_GetItem(obj4, i));
+ arg5[i] = NULL;
+ } else {
+ SWIG_exception(SWIG_TypeError, "expected sequence");
}
}
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
result = ldb_search(arg1,arg2,arg3,(char const *)arg4,(char const *const *)arg5,arg6);
- {
- if (result != 0) {
- PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
- SWIG_fail;
- }
- resultobj = Py_None;
+ if (result != 0) {
+ PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
+ SWIG_fail;
}
+ resultobj = Py_None;
{
resultobj = PyList_New((*arg6)->count);
for (i6 = 0; i6 < (*arg6)->count; i6++) {
@@ -4454,12 +4416,14 @@ SWIGINTERN PyObject *_wrap_Ldb_search(PyObject *SWIGUNUSEDPARM(self), PyObject *
);
}
}
+ talloc_free(arg2);
if (alloc4 == SWIG_NEWOBJ) free((char*)buf4);
{
talloc_free(arg5);
}
return resultobj;
fail:
+ talloc_free(arg2);
if (alloc4 == SWIG_NEWOBJ) free((char*)buf4);
{
talloc_free(arg5);
@@ -4475,8 +4439,6 @@ SWIGINTERN PyObject *_wrap_Ldb_delete(PyObject *SWIGUNUSEDPARM(self), PyObject *
ldb_error result;
void *argp1 = 0 ;
int res1 = 0 ;
- void *argp2 = 0 ;
- int res2 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
char * kwnames[] = {
@@ -4489,26 +4451,22 @@ SWIGINTERN PyObject *_wrap_Ldb_delete(PyObject *SWIGUNUSEDPARM(self), PyObject *
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb_delete" "', argument " "1"" of type '" "ldb *""'");
}
arg1 = (ldb *)(argp1);
- res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_dn, 0 | 0 );
- if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Ldb_delete" "', argument " "2"" of type '" "ldb_dn *""'");
- }
- arg2 = (ldb_dn *)(argp2);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
+ if (ldb_dn_from_pyobject(NULL, obj1, arg1, &arg2) != 0) {
+ SWIG_fail;
}
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
result = ldb_delete(arg1,arg2);
- {
- if (result != 0) {
- PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
- SWIG_fail;
- }
- resultobj = Py_None;
+ if (result != 0) {
+ PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
+ SWIG_fail;
}
+ resultobj = Py_None;
+ talloc_free(arg2);
return resultobj;
fail:
+ talloc_free(arg2);
return NULL;
}
@@ -4521,10 +4479,6 @@ SWIGINTERN PyObject *_wrap_Ldb_rename(PyObject *SWIGUNUSEDPARM(self), PyObject *
ldb_error result;
void *argp1 = 0 ;
int res1 = 0 ;
- void *argp2 = 0 ;
- int res2 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
@@ -4538,31 +4492,27 @@ SWIGINTERN PyObject *_wrap_Ldb_rename(PyObject *SWIGUNUSEDPARM(self), PyObject *
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb_rename" "', argument " "1"" of type '" "ldb *""'");
}
arg1 = (ldb *)(argp1);
- res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_dn, 0 | 0 );
- if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Ldb_rename" "', argument " "2"" of type '" "ldb_dn *""'");
- }
- arg2 = (ldb_dn *)(argp2);
- res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_ldb_dn, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Ldb_rename" "', argument " "3"" of type '" "ldb_dn *""'");
+ if (ldb_dn_from_pyobject(NULL, obj1, arg1, &arg2) != 0) {
+ SWIG_fail;
}
- arg3 = (ldb_dn *)(argp3);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
+ if (ldb_dn_from_pyobject(NULL, obj2, arg1, &arg3) != 0) {
+ SWIG_fail;
}
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
result = ldb_rename(arg1,arg2,arg3);
- {
- if (result != 0) {
- PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
- SWIG_fail;
- }
- resultobj = Py_None;
+ if (result != 0) {
+ PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
+ SWIG_fail;
}
+ resultobj = Py_None;
+ talloc_free(arg2);
+ talloc_free(arg3);
return resultobj;
fail:
+ talloc_free(arg2);
+ talloc_free(arg3);
return NULL;
}
@@ -4588,24 +4538,18 @@ SWIGINTERN PyObject *_wrap_Ldb_add__SWIG_0(PyObject *SWIGUNUSEDPARM(self), int n
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Ldb_add" "', argument " "2"" of type '" "ldb_msg *""'");
}
arg2 = (ldb_msg *)(argp2);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
- {
- if (arg2 == NULL)
- SWIG_exception(SWIG_ValueError,
- "Message can not be None");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
+ if (arg2 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "Message can not be None");
result = ldb_add(arg1,arg2);
- {
- if (result != 0) {
- PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
- SWIG_fail;
- }
- resultobj = Py_None;
+ if (result != 0) {
+ PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
+ SWIG_fail;
}
+ resultobj = Py_None;
return resultobj;
fail:
return NULL;
@@ -4627,19 +4571,15 @@ SWIGINTERN PyObject *_wrap_Ldb_add__SWIG_1(PyObject *SWIGUNUSEDPARM(self), int n
}
arg1 = (ldb *)(argp1);
arg2 = swig_obj[1];
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
result = ldb_add__SWIG_1(arg1,arg2);
- {
- if (result != 0) {
- PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
- SWIG_fail;
- }
- resultobj = Py_None;
+ if (result != 0) {
+ PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
+ SWIG_fail;
}
+ resultobj = Py_None;
return resultobj;
fail:
return NULL;
@@ -4700,24 +4640,18 @@ SWIGINTERN PyObject *_wrap_Ldb_modify(PyObject *SWIGUNUSEDPARM(self), PyObject *
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Ldb_modify" "', argument " "2"" of type '" "ldb_msg *""'");
}
arg2 = (ldb_msg *)(argp2);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
- {
- if (arg2 == NULL)
- SWIG_exception(SWIG_ValueError,
- "Message can not be None");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
+ if (arg2 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "Message can not be None");
result = ldb_modify(arg1,arg2);
- {
- if (result != 0) {
- PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
- SWIG_fail;
- }
- resultobj = Py_None;
+ if (result != 0) {
+ PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
+ SWIG_fail;
}
+ resultobj = Py_None;
return resultobj;
fail:
return NULL;
@@ -4739,11 +4673,9 @@ SWIGINTERN PyObject *_wrap_Ldb_get_config_basedn(PyObject *SWIGUNUSEDPARM(self),
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb_get_config_basedn" "', argument " "1"" of type '" "ldb *""'");
}
arg1 = (ldb *)(argp1);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
result = (ldb_dn *)ldb_get_config_basedn(arg1);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_dn, 0 | 0 );
return resultobj;
@@ -4767,11 +4699,9 @@ SWIGINTERN PyObject *_wrap_Ldb_get_root_basedn(PyObject *SWIGUNUSEDPARM(self), P
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb_get_root_basedn" "', argument " "1"" of type '" "ldb *""'");
}
arg1 = (ldb *)(argp1);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
result = (ldb_dn *)ldb_get_root_basedn(arg1);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_dn, 0 | 0 );
return resultobj;
@@ -4795,11 +4725,9 @@ SWIGINTERN PyObject *_wrap_Ldb_get_schema_basedn(PyObject *SWIGUNUSEDPARM(self),
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb_get_schema_basedn" "', argument " "1"" of type '" "ldb *""'");
}
arg1 = (ldb *)(argp1);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
result = (ldb_dn *)ldb_get_schema_basedn(arg1);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_dn, 0 | 0 );
return resultobj;
@@ -4823,11 +4751,9 @@ SWIGINTERN PyObject *_wrap_Ldb_get_default_basedn(PyObject *SWIGUNUSEDPARM(self)
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb_get_default_basedn" "', argument " "1"" of type '" "ldb *""'");
}
arg1 = (ldb *)(argp1);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
result = (ldb_dn *)ldb_get_default_basedn(arg1);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_dn, 0 | 0 );
return resultobj;
@@ -4851,11 +4777,9 @@ SWIGINTERN PyObject *_wrap_Ldb_errstring(PyObject *SWIGUNUSEDPARM(self), PyObjec
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb_errstring" "', argument " "1"" of type '" "ldb *""'");
}
arg1 = (ldb *)(argp1);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
result = (char *)ldb_errstring(arg1);
resultobj = SWIG_FromCharPtr((const char *)result);
return resultobj;
@@ -4889,11 +4813,9 @@ SWIGINTERN PyObject *_wrap_Ldb_set_create_perms(PyObject *SWIGUNUSEDPARM(self),
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Ldb_set_create_perms" "', argument " "2"" of type '" "unsigned int""'");
}
arg2 = (unsigned int)(val2);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
ldb_set_create_perms(arg1,arg2);
resultobj = SWIG_Py_Void();
return resultobj;
@@ -4928,11 +4850,9 @@ SWIGINTERN PyObject *_wrap_Ldb_set_modules_dir(PyObject *SWIGUNUSEDPARM(self), P
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Ldb_set_modules_dir" "', argument " "2"" of type '" "char const *""'");
}
arg2 = (char *)(buf2);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
ldb_set_modules_dir(arg1,(char const *)arg2);
resultobj = SWIG_Py_Void();
if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
@@ -4970,19 +4890,15 @@ SWIGINTERN PyObject *_wrap_Ldb_set_debug(PyObject *SWIGUNUSEDPARM(self), PyObjec
Py_INCREF(obj1);
arg3 = obj1;
}
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
result = ldb_set_debug(arg1,arg2,arg3);
- {
- if (result != 0) {
- PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
- SWIG_fail;
- }
- resultobj = Py_None;
+ if (result != 0) {
+ PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
+ SWIG_fail;
}
+ resultobj = Py_None;
return resultobj;
fail:
return NULL;
@@ -5023,19 +4939,15 @@ SWIGINTERN PyObject *_wrap_Ldb_set_opaque(PyObject *SWIGUNUSEDPARM(self), PyObje
if (!SWIG_IsOK(res3)) {
SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Ldb_set_opaque" "', argument " "3"" of type '" "void *""'");
}
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
result = ldb_set_opaque(arg1,(char const *)arg2,arg3);
- {
- if (result != 0) {
- PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
- SWIG_fail;
- }
- resultobj = Py_None;
+ if (result != 0) {
+ PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
+ SWIG_fail;
}
+ resultobj = Py_None;
if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
return resultobj;
fail:
@@ -5071,11 +4983,9 @@ SWIGINTERN PyObject *_wrap_Ldb_get_opaque(PyObject *SWIGUNUSEDPARM(self), PyObje
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Ldb_get_opaque" "', argument " "2"" of type '" "char const *""'");
}
arg2 = (char *)(buf2);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
result = (void *)ldb_get_opaque(arg1,(char const *)arg2);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 );
if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
@@ -5101,19 +5011,15 @@ SWIGINTERN PyObject *_wrap_Ldb_transaction_start(PyObject *SWIGUNUSEDPARM(self),
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb_transaction_start" "', argument " "1"" of type '" "ldb *""'");
}
arg1 = (ldb *)(argp1);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
result = ldb_transaction_start(arg1);
- {
- if (result != 0) {
- PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
- SWIG_fail;
- }
- resultobj = Py_None;
+ if (result != 0) {
+ PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
+ SWIG_fail;
}
+ resultobj = Py_None;
return resultobj;
fail:
return NULL;
@@ -5135,19 +5041,15 @@ SWIGINTERN PyObject *_wrap_Ldb_transaction_commit(PyObject *SWIGUNUSEDPARM(self)
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb_transaction_commit" "', argument " "1"" of type '" "ldb *""'");
}
arg1 = (ldb *)(argp1);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
result = ldb_transaction_commit(arg1);
- {
- if (result != 0) {
- PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
- SWIG_fail;
- }
- resultobj = Py_None;
+ if (result != 0) {
+ PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
+ SWIG_fail;
}
+ resultobj = Py_None;
return resultobj;
fail:
return NULL;
@@ -5169,19 +5071,15 @@ SWIGINTERN PyObject *_wrap_Ldb_transaction_cancel(PyObject *SWIGUNUSEDPARM(self)
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb_transaction_cancel" "', argument " "1"" of type '" "ldb *""'");
}
arg1 = (ldb *)(argp1);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
result = ldb_transaction_cancel(arg1);
- {
- if (result != 0) {
- PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
- SWIG_fail;
- }
- resultobj = Py_None;
+ if (result != 0) {
+ PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
+ SWIG_fail;
}
+ resultobj = Py_None;
return resultobj;
fail:
return NULL;
@@ -5196,8 +5094,6 @@ SWIGINTERN PyObject *_wrap_Ldb___contains__(PyObject *SWIGUNUSEDPARM(self), PyOb
ldb_error result;
void *argp1 = 0 ;
int res1 = 0 ;
- void *argp2 = 0 ;
- int res2 = 0 ;
struct ldb_result *tmp3 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
@@ -5214,32 +5110,28 @@ SWIGINTERN PyObject *_wrap_Ldb___contains__(PyObject *SWIGUNUSEDPARM(self), PyOb
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb___contains__" "', argument " "1"" of type '" "ldb *""'");
}
arg1 = (ldb *)(argp1);
- res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_dn, 0 | 0 );
- if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Ldb___contains__" "', argument " "2"" of type '" "ldb_dn *""'");
- }
- arg2 = (ldb_dn *)(argp2);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
+ if (ldb_dn_from_pyobject(NULL, obj1, arg1, &arg2) != 0) {
+ SWIG_fail;
}
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
result = ldb___contains__(arg1,arg2,arg3);
- {
- if (result != 0) {
- PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
- SWIG_fail;
- }
- resultobj = Py_None;
+ if (result != 0) {
+ PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
+ SWIG_fail;
}
+ resultobj = Py_None;
{
resultobj = ((*arg3)->count > 0)?Py_True:Py_False;
}
+ talloc_free(arg2);
{
talloc_free(*arg3);
}
return resultobj;
fail:
+ talloc_free(arg2);
{
talloc_free(*arg3);
}
@@ -5274,11 +5166,9 @@ SWIGINTERN PyObject *_wrap_Ldb_parse_ldif(PyObject *SWIGUNUSEDPARM(self), PyObje
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Ldb_parse_ldif" "', argument " "2"" of type '" "char const *""'");
}
arg2 = (char *)(buf2);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
result = (PyObject *)ldb_parse_ldif(arg1,(char const *)arg2);
resultobj = result;
if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
@@ -5397,13 +5287,11 @@ SWIGINTERN PyObject *_wrap_register_module(PyObject *SWIGUNUSEDPARM(self), PyObj
arg1->name = PyObject_GetAttrString(obj0, "name");
}
result = ldb_register_module((struct ldb_module_ops const *)arg1);
- {
- if (result != 0) {
- PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
- SWIG_fail;
- }
- resultobj = Py_None;
+ if (result != 0) {
+ PyErr_SetObject(PyExc_LdbError, Py_BuildValue("(i,s)", result, ldb_strerror(result)));
+ SWIG_fail;
}
+ resultobj = Py_None;
return resultobj;
fail:
return NULL;
diff --git a/source4/lib/ldb/tests/python/api.py b/source4/lib/ldb/tests/python/api.py
index c280a3f3c4..d9dfce8718 100755
--- a/source4/lib/ldb/tests/python/api.py
+++ b/source4/lib/ldb/tests/python/api.py
@@ -52,6 +52,10 @@ class SimpleLdb(unittest.TestCase):
l = ldb.Ldb("foo.tdb")
self.assertEquals(len(l.search(ldb.Dn(l, ""), ldb.SCOPE_SUBTREE, "(dc=*)", ["dc"])), 0)
+ def test_search_string_dn(self):
+ l = ldb.Ldb("foo.tdb")
+ self.assertEquals(len(l.search("", ldb.SCOPE_SUBTREE, "(dc=*)", ["dc"])), 0)
+
def test_opaque(self):
l = ldb.Ldb("foo.tdb")
l.set_opaque("my_opaque", l)
@@ -142,6 +146,19 @@ class SimpleLdb(unittest.TestCase):
finally:
l.delete(ldb.Dn(l, "dc=bar"))
+ def test_rename_string_dns(self):
+ l = ldb.Ldb("foo.tdb")
+ m = ldb.Message()
+ m.dn = ldb.Dn(l, "dc=foo")
+ m["bla"] = "bla"
+ self.assertEquals(len(l.search()), 1)
+ l.add(m)
+ try:
+ l.rename("dc=foo", "dc=bar")
+ self.assertEquals(len(l.search()), 2)
+ finally:
+ l.delete(ldb.Dn(l, "dc=bar"))
+
def test_modify_delete(self):
l = ldb.Ldb("foo.tdb")
m = ldb.Message()
diff --git a/source4/lib/ldb/tests/python/ldap.py b/source4/lib/ldb/tests/python/ldap.py
new file mode 100755
index 0000000000..519e228fca
--- /dev/null
+++ b/source4/lib/ldb/tests/python/ldap.py
@@ -0,0 +1,1355 @@
+#!/usr/bin/python
+# This is a port of the original in testprogs/ejs/ldap.js
+
+import sys
+
+if len(sys.argv) < 2:
+ print "Usage: %s <HOST>" % sys.argv[0]
+ sys.exit(1)
+
+host = sys.argv[1]
+
+def assertEquals(a1, a2):
+ assert a1 == a2
+
+def basic_tests(ldb, gc_ldb, base_dn, configuration_dn, schema_dn):
+ print "Running basic tests"
+
+ ldb.delete("cn=ldaptestuser,cn=users," + base_dn)
+ ldb.delete("cn=ldaptestgroup,cn=users," + base_dn)
+
+ print "Testing group add with invalid member"
+ ok = ldb.add({
+ "dn": "cn=ldaptestgroup,cn=uSers," + base_dn,
+ "objectclass": "group",
+ "member": "cn=ldaptestuser,cn=useRs," + base_dn})
+
+ if (ok.error != 32) { # LDAP_NO_SUCH_OBJECT
+ print ok.errstr
+ assertEquals(ok.error, 32)
+ }
+
+ print "Testing user add"
+ ok = ldb.add({
+ "dn": "cn=ldaptestuser,cn=uSers," + base_dn,
+ "objectclass": ["user", "person"],
+ "cN": "LDAPtestUSER",
+ "givenname": "ldap",
+ "sn": "testy"})
+ if (ok.error != 0) {
+ ok = ldb.delete("cn=ldaptestuser,cn=users," + base_dn)
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+ ok = ldb.add({
+ "dn": "cn=ldaptestuser,cn=uSers," + base_dn,
+ "objectclass": ["user", "person"],
+ "cN": "LDAPtestUSER",
+ "givenname": "ldap",
+ "sn": "testy"})
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+ }
+
+ ok = ldb.add({
+ "dn": "cn=ldaptestgroup,cn=uSers," + base_dn,
+ "objectclass": "group",
+ "member": "cn=ldaptestuser,cn=useRs," + base_dn})
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ ok = ldb.add({
+ "dn": "cn=ldaptestcomputer,cn=computers," + base_dn,
+ "objectclass": "computer",
+ "cN": "LDAPtestCOMPUTER"})
+ if (ok.error != 0) {
+ ok = ldb.delete("cn=ldaptestcomputer,cn=computers," + base_dn)
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+ ok = ldb.add({
+ "dn": "cn=ldaptestcomputer,cn=computers," + base_dn,
+ "objectClass": "computer",
+ "cn": "LDAPtestCOMPUTER"})
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+ }
+
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ ok = ldb.add({"dn": "cn=ldaptest2computer,cn=computers," + base_dn,
+ "objectClass": "computer",
+ "cn": "LDAPtest2COMPUTER",
+ "userAccountControl": "4096",
+ "displayname": "ldap testy"})
+ if (ok.error != 0) {
+ ok = ldb.delete("cn=ldaptest2computer,cn=computers," + base_dn)
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+ ok = ldb.add({
+ "dn": "cn=ldaptest2computer,cn=computers," + base_dn,
+ "objectClass": "computer",
+ "cn": "LDAPtest2COMPUTER",
+ "userAccountControl": "4096",
+ "displayname": "ldap testy"})
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+ }
+
+ print "Testing attribute or value exists behaviour"
+ ok = ldb.modify("
+dn: cn=ldaptest2computer,cn=computers," + base_dn + "
+changetype: modify
+replace: servicePrincipalName
+servicePrincipalName: host/ldaptest2computer
+servicePrincipalName: host/ldaptest2computer
+servicePrincipalName: cifs/ldaptest2computer
+")
+
+#LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS
+ if (ok.error != 20) {
+ print "Expected error LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS, got :" + ok.errstr
+ assertEquals(ok.error, 20)
+ }
+
+ ok = ldb.modify("
+dn: cn=ldaptest2computer,cn=computers," + base_dn + "
+changetype: modify
+replace: servicePrincipalName
+servicePrincipalName: host/ldaptest2computer
+servicePrincipalName: cifs/ldaptest2computer
+")
+
+ if (ok.error != 0) {
+ print "Failed to replace servicePrincpalName:" + ok.errstr
+ assertEquals(ok.error, 20)
+ }
+
+ ok = ldb.modify("
+dn: cn=ldaptest2computer,cn=computers," + base_dn + "
+changetype: modify
+add: servicePrincipalName
+servicePrincipalName: host/ldaptest2computer
+")
+
+#LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS
+ if (ok.error != 20) {
+ print "Expected error LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS, got :" + ok.errstr
+ assertEquals(ok.error, 20)
+ }
+
+ print "Testing ranged results"
+ ok = ldb.modify("
+dn: cn=ldaptest2computer,cn=computers," + base_dn + "
+changetype: modify
+replace: servicePrincipalName
+")
+ if (ok.error != 0) {
+ print "Failed to replace servicePrincpalName:" + ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ ok = ldb.modify("
+dn: cn=ldaptest2computer,cn=computers," + base_dn + "
+changetype: modify
+add: servicePrincipalName
+servicePrincipalName: host/ldaptest2computer0
+servicePrincipalName: host/ldaptest2computer1
+servicePrincipalName: host/ldaptest2computer2
+servicePrincipalName: host/ldaptest2computer3
+servicePrincipalName: host/ldaptest2computer4
+servicePrincipalName: host/ldaptest2computer5
+servicePrincipalName: host/ldaptest2computer6
+servicePrincipalName: host/ldaptest2computer7
+servicePrincipalName: host/ldaptest2computer8
+servicePrincipalName: host/ldaptest2computer9
+servicePrincipalName: host/ldaptest2computer10
+servicePrincipalName: host/ldaptest2computer11
+servicePrincipalName: host/ldaptest2computer12
+servicePrincipalName: host/ldaptest2computer13
+servicePrincipalName: host/ldaptest2computer14
+servicePrincipalName: host/ldaptest2computer15
+servicePrincipalName: host/ldaptest2computer16
+servicePrincipalName: host/ldaptest2computer17
+servicePrincipalName: host/ldaptest2computer18
+servicePrincipalName: host/ldaptest2computer19
+servicePrincipalName: host/ldaptest2computer20
+servicePrincipalName: host/ldaptest2computer21
+servicePrincipalName: host/ldaptest2computer22
+servicePrincipalName: host/ldaptest2computer23
+servicePrincipalName: host/ldaptest2computer24
+servicePrincipalName: host/ldaptest2computer25
+servicePrincipalName: host/ldaptest2computer26
+servicePrincipalName: host/ldaptest2computer27
+servicePrincipalName: host/ldaptest2computer28
+servicePrincipalName: host/ldaptest2computer29
+")
+
+ if (ok.error != 0) {
+ print "Failed to replace servicePrincpalName:" + ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ res = ldb.search(base_dn, expression="(cn=ldaptest2computer))", scope=ldb.SCOPE_SUBTREE,
+ attrs=["servicePrincipalName;range=0-*"])
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (cn=ldaptest2computer)"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+# print res[0]["servicePrincipalName;range=0-*"].length
+ assertEquals(res[0]["servicePrincipalName;range=0-*"].length, 30)
+
+ attrs = ["servicePrincipalName;range=0-19"]
+ res = ldb.search("(cn=ldaptest2computer))", base_dn, ldb.SCOPE_SUBTREE, attrs)
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (cn=ldaptest2computer)"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+# print res[0]["servicePrincipalName;range=0-19"].length
+ assertEquals(res[0]["servicePrincipalName;range=0-19"].length, 20)
+
+ attrs = ["servicePrincipalName;range=0-30"]
+ res = ldb.search("(cn=ldaptest2computer))", base_dn, ldb.SCOPE_SUBTREE, attrs)
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (cn=ldaptest2computer)"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+ assertEquals(res[0]["servicePrincipalName;range=0-*"].length, 30)
+
+ attrs = ["servicePrincipalName;range=0-40"]
+ res = ldb.search("(cn=ldaptest2computer))", base_dn, ldb.SCOPE_SUBTREE, attrs)
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (cn=ldaptest2computer)"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+ assertEquals(res[0]["servicePrincipalName;range=0-*"].length, 30)
+
+ attrs = ["servicePrincipalName;range=30-40"]
+ res = ldb.search("(cn=ldaptest2computer))", base_dn, ldb.SCOPE_SUBTREE, attrs)
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (cn=ldaptest2computer)"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+ assertEquals(res[0]["servicePrincipalName;range=30-*"].length, 0)
+
+ attrs = ["servicePrincipalName;range=10-40"]
+ res = ldb.search("(cn=ldaptest2computer))", base_dn, ldb.SCOPE_SUBTREE, attrs)
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (cn=ldaptest2computer)"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+ assertEquals(res[0]["servicePrincipalName;range=10-*"].length, 20)
+# pos_11 = res[0]["servicePrincipalName;range=10-*"][18]
+
+ attrs = ["servicePrincipalName;range=11-40"]
+ res = ldb.search("(cn=ldaptest2computer))", base_dn, ldb.SCOPE_SUBTREE, attrs)
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (cn=ldaptest2computer)"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+ assertEquals(res[0]["servicePrincipalName;range=11-*"].length, 19)
+# print res[0]["servicePrincipalName;range=11-*"][18]
+# print pos_11
+# assertEquals((res[0]["servicePrincipalName;range=11-*"][18]), pos_11)
+
+ attrs = ["servicePrincipalName;range=11-15"]
+ res = ldb.search("(cn=ldaptest2computer))", base_dn, ldb.SCOPE_SUBTREE, attrs)
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (cn=ldaptest2computer)"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+ assertEquals(res[0]["servicePrincipalName;range=11-15"].length, 5)
+# assertEquals(res[0]["servicePrincipalName;range=11-15"][4], pos_11)
+
+ attrs = ["servicePrincipalName"]
+ res = ldb.search("(cn=ldaptest2computer))", base_dn, ldb.SCOPE_SUBTREE, attrs)
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (cn=ldaptest2computer)"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+# print res[0]["servicePrincipalName"][18]
+# print pos_11
+ assertEquals(res[0]["servicePrincipalName"].length, 30)
+# assertEquals(res[0]["servicePrincipalName"][18], pos_11)
+
+ ok = ldb.add({
+ "dn": "cn=ldaptestuser2,cn=useRs," + base_dn,
+ "objectClass": ["person", "user"],
+ "cn": "LDAPtestUSER2",
+ "givenname": "testy",
+ "sn": "ldap user2"})
+ if (ok.error != 0) {
+ ok = ldb.delete("cn=ldaptestuser2,cn=users," + base_dn)
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+ ok = ldb.add({
+ "dn": "cn=ldaptestuser2,cn=useRs," + base_dn,
+ "objectClass": ["person", "user"],
+ "cn": "LDAPtestUSER2",
+ "givenname": "testy",
+ "sn": "ldap user2"})
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+ }
+
+
+ print "Testing Ambigious Name Resolution"
+# Testing ldb.search for (&(anr=ldap testy)(objectClass=user))
+ res = ldb.search("(&(anr=ldap testy)(objectClass=user))")
+ if (res.error != 0 || len(res) != 3) {
+ print "Could not find (&(anr=ldap testy)(objectClass=user))"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 3)
+ }
+
+# Testing ldb.search for (&(anr=testy ldap)(objectClass=user))
+ res = ldb.search("(&(anr=testy ldap)(objectClass=user))")
+ if (res.error != 0 || len(res) != 2) {
+ print "Found only " + len(res) + " for (&(anr=testy ldap)(objectClass=user))"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 2)
+ }
+
+# Testing ldb.search for (&(anr=ldap)(objectClass=user))
+ res = ldb.search("(&(anr=ldap)(objectClass=user))")
+ if (res.error != 0 || len(res) != 4) {
+ print "Found only " + len(res) + " for (&(anr=ldap)(objectClass=user))"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 4)
+ }
+
+# Testing ldb.search for (&(anr==ldap)(objectClass=user))
+ res = ldb.search("(&(anr==ldap)(objectClass=user))")
+ if (res.error != 0 || len(res) != 1) {
+ print "Found only " + len(res) + " for (&(anr=ldap)(objectClass=user))"
+ print "Could not find (&(anr==ldap)(objectClass=user))"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+
+ assertEquals(res[0].dn, ("CN=ldaptestuser,CN=Users," + base_dn))
+ assertEquals(res[0].cn, "ldaptestuser")
+ assertEquals(res[0].name, "ldaptestuser")
+
+# Testing ldb.search for (&(anr=testy)(objectClass=user))
+ res = ldb.search("(&(anr=testy)(objectClass=user))")
+ if (res.error != 0 || len(res) != 2) {
+ print "Found only " + len(res) + " for (&(anr=testy)(objectClass=user))"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 2)
+ }
+
+# Testing ldb.search for (&(anr=ldap testy)(objectClass=user))
+ res = ldb.search("(&(anr=testy ldap)(objectClass=user))")
+ if (res.error != 0 || len(res) != 2) {
+ print "Found only " + len(res) + " for (&(anr=ldap testy)(objectClass=user))"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 2)
+ }
+
+# Testing ldb.search for (&(anr==ldap testy)(objectClass=user))
+ res = ldb.search("(&(anr==testy ldap)(objectClass=user))")
+ if (res.error != 0 || len(res) != 1) {
+ print "Found only " + len(res) + " for (&(anr==ldap testy)(objectClass=user))"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+
+ assertEquals(res[0].dn, ("CN=ldaptestuser,CN=Users," + base_dn))
+ assertEquals(res[0].cn, "ldaptestuser")
+ assertEquals(res[0].name, "ldaptestuser")
+
+# Testing ldb.search for (&(anr==testy ldap)(objectClass=user))
+ res = ldb.search("(&(anr==testy ldap)(objectClass=user))")
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (&(anr==testy ldap)(objectClass=user))"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+
+ assertEquals(res[0].dn, ("CN=ldaptestuser,CN=Users," + base_dn))
+ assertEquals(res[0].cn, "ldaptestuser")
+ assertEquals(res[0].name, "ldaptestuser")
+
+ # Testing ldb.search for (&(anr=testy ldap user)(objectClass=user))
+ res = ldb.search("(&(anr=testy ldap user)(objectClass=user))")
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (&(anr=testy ldap user)(objectClass=user))"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+
+ assertEquals(res[0].dn, ("CN=ldaptestuser2,CN=Users," + base_dn))
+ assertEquals(res[0].cn, "ldaptestuser2")
+ assertEquals(res[0].name, "ldaptestuser2")
+
+ # Testing ldb.search for (&(anr==testy ldap user2)(objectClass=user))
+ res = ldb.search("(&(anr==testy ldap user2)(objectClass=user))")
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (&(anr==testy ldap user2)(objectClass=user))"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+
+ assertEquals(res[0].dn, ("CN=ldaptestuser2,CN=Users," + base_dn))
+ assertEquals(res[0].cn, "ldaptestuser2")
+ assertEquals(res[0].name, "ldaptestuser2")
+
+ # Testing ldb.search for (&(anr==ldap user2)(objectClass=user))
+ res = ldb.search("(&(anr==ldap user2)(objectClass=user))")
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (&(anr==ldap user2)(objectClass=user))"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+
+ assertEquals(res[0].dn, ("CN=ldaptestuser2,CN=Users," + base_dn))
+ assertEquals(res[0].cn, "ldaptestuser2")
+ assertEquals(res[0].name, "ldaptestuser2")
+
+ # Testing ldb.search for (&(anr==not ldap user2)(objectClass=user))
+ res = ldb.search("(&(anr==not ldap user2)(objectClass=user))")
+ if (res.error != 0 || len(res) != 0) {
+ print "Must not find (&(anr==not ldap user2)(objectClass=user))"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 0)
+ }
+
+ # Testing ldb.search for (&(anr=not ldap user2)(objectClass=user))
+ res = ldb.search("(&(anr=not ldap user2)(objectClass=user))")
+ if (res.error != 0 || len(res) != 0) {
+ print "Must not find (&(anr=not ldap user2)(objectClass=user))"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 0)
+ }
+
+ print "Testing Group Modifies"
+ ok = ldb.modify("
+dn: cn=ldaptestgroup,cn=users," + base_dn + "
+changetype: modify
+add: member
+member: cn=ldaptestuser2,cn=users," + base_dn + "
+member: cn=ldaptestcomputer,cn=computers," + base_dn + "
+")
+
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ ok = ldb.delete("cn=ldaptestuser3,cn=users," + base_dn)
+
+ print "Testing adding non-existent user to a group"
+ ok = ldb.modify("
+dn: cn=ldaptestgroup,cn=users," + base_dn + "
+changetype: modify
+add: member
+member: cn=ldaptestuser3,cn=users," + base_dn + "
+")
+ if (ok.error != 32) { # LDAP_NO_SUCH_OBJECT
+ print ok.errstr
+ assertEquals(ok.error, 32)
+ }
+
+ print "Testing Renames"
+
+ ok = ldb.rename("cn=ldaptestuser2,cn=users," + base_dn, "cn=ldaptestuser3,cn=users," + base_dn)
+ if (ok.error != 0) {
+ print "Could not rename cn=ldaptestuser2,cn=users," + base_dn + " into cn=ldaptestuser3,cn=users," + base_dn + ": " + ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ ok = ldb.rename("cn=ldaptestuser3,cn=users," + base_dn, "cn=ldaptestuser3,cn=users," + base_dn)
+ if (ok.error != 0) {
+ print "Could not rename cn=ldaptestuser3,cn=users," + base_dn + " onto itself: " + ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ ok = ldb.rename("cn=ldaptestuser3,cn=users," + base_dn, "cn=ldaptestUSER3,cn=users," + base_dn)
+ if (ok.error != 0) {
+ print "Could not rename cn=ldaptestuser3,cn=users," + base_dn + " into cn=ldaptestUSER3,cn=users," + base_dn + ": " + ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ print "Testing ldb.search for (&(cn=ldaptestuser3)(objectClass=user))"
+ res = ldb.search("(&(cn=ldaptestuser3)(objectClass=user))")
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (&(cn=ldaptestuser3)(objectClass=user))"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+
+ assertEquals(res[0].dn, ("CN=ldaptestUSER3,CN=Users," + base_dn))
+ assertEquals(res[0].cn, "ldaptestUSER3")
+ assertEquals(res[0].name, "ldaptestUSER3")
+
+# This is a Samba special, and does not exist in real AD
+# print "Testing ldb.search for (dn=CN=ldaptestUSER3,CN=Users," + base_dn + ")"
+# res = ldb.search("(dn=CN=ldaptestUSER3,CN=Users," + base_dn + ")")
+# if (res.error != 0 || len(res) != 1) {
+# print "Could not find (dn=CN=ldaptestUSER3,CN=Users," + base_dn + ")"
+# assertEquals(res.error, 0)
+# assertEquals(len(res), 1)
+# }
+# assertEquals(res[0].dn, ("CN=ldaptestUSER3,CN=Users," + base_dn))
+# assertEquals(res[0].cn, "ldaptestUSER3")
+# assertEquals(res[0].name, "ldaptestUSER3")
+
+ print "Testing ldb.search for (distinguishedName=CN=ldaptestUSER3,CN=Users," + base_dn + ")"
+ res = ldb.search("(distinguishedName=CN=ldaptestUSER3,CN=Users," + base_dn + ")")
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (dn=CN=ldaptestUSER3,CN=Users," + base_dn + ")"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+ assertEquals(res[0].dn, ("CN=ldaptestUSER3,CN=Users," + base_dn))
+ assertEquals(res[0].cn, "ldaptestUSER3")
+ assertEquals(res[0].name, "ldaptestUSER3")
+
+ # ensure we cannot add it again
+ ok = ldb.add({"dn": "cn=ldaptestuser3,cn=userS," + base_dn,
+ "objectClass": ["person", "user"],
+ "cn": "LDAPtestUSER3"})
+#LDB_ERR_ENTRY_ALREADY_EXISTS
+ if (ok.error != 68) {
+ print "expected error LDB_ERR_ENTRY_ALREADY_EXISTS, got: " + ok.errstr
+ assertEquals(ok.error, 68)
+ }
+
+ # rename back
+ ok = ldb.rename("cn=ldaptestuser3,cn=users," + base_dn, "cn=ldaptestuser2,cn=users," + base_dn)
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ # ensure we cannnot rename it twice
+ ok = ldb.rename("cn=ldaptestuser3,cn=users," + base_dn, "cn=ldaptestuser2,cn=users," + base_dn)
+#LDB_ERR_NO_SUCH_OBJECT
+ assertEquals(ok.error, 32)
+
+ # ensure can now use that name
+ ok = ldb.add({"dn": "cn=ldaptestuser3,cn=users," + base_dn,
+ "objectClass": ["person", "user"],
+ "cn": "LDAPtestUSER3"})
+
+ # ensure we now cannnot rename
+ ok = ldb.rename("cn=ldaptestuser2,cn=users," + base_dn, "cn=ldaptestuser3,cn=users," + base_dn)
+#LDB_ERR_ENTRY_ALREADY_EXISTS
+ if (ok.error != 68) {
+ print "expected error LDB_ERR_ENTRY_ALREADY_EXISTS, got: " + ok.errstr
+ assertEquals(ok.error, 68)
+ }
+ assertEquals(ok.error, 68)
+ ok = ldb.rename("cn=ldaptestuser3,cn=users," + base_dn, "cn=ldaptestuser3,cn=configuration," + base_dn)
+ if (ok.error != 71 && ok.error != 64) {
+ print "expected error LDB_ERR_ENTRY_ALREADY_EXISTS or LDAP_NAMING_VIOLATION, got: " + ok.errstr
+ assertEquals(ok.error == 71 || ok.error, 64)
+ }
+ assertEquals(ok.error == 71 || ok.error, 64)
+
+ ok = ldb.rename("cn=ldaptestuser3,cn=users," + base_dn, "cn=ldaptestuser5,cn=users," + base_dn)
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ ok = ldb.delete("cn=ldaptestuser5,cn=users," + base_dn)
+
+ ok = ldb.delete("cn=ldaptestgroup2,cn=users," + base_dn)
+
+ ok = ldb.rename("cn=ldaptestgroup,cn=users," + base_dn, "cn=ldaptestgroup2,cn=users," + base_dn)
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ print "Testing subtree Renames"
+
+ ok = ldb.add({"dn": "cn=ldaptestcontainer," + base_dn, "objectClass": "container"})
+
+ ok = ldb.add({"dn": "CN=ldaptestuser4,CN=ldaptestcontainer," + base_dn,
+ "objectClass": ["person", "user"],
+ "cn": "LDAPtestUSER4"})
+ if (ok.error != 0) {
+ ok = ldb.delete("cn=ldaptestuser4,cn=ldaptestcontainer," + base_dn)
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+ ok = ldb.add({"dn": "CN=ldaptestuser4,CN=ldaptestcontainer," + base_dn,
+ "objectClass": ["person", "user"],
+ "cn": "LDAPtestUSER4"})
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+ }
+
+ ok = ldb.modify("
+dn: cn=ldaptestgroup2,cn=users," + base_dn + "
+changetype: modify
+add: member
+member: cn=ldaptestuser4,cn=ldaptestcontainer," + base_dn + "
+")
+ if (ok.error != 0) {
+ print "Failure adding ldaptestuser4 to a group"
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ print "Testing ldb.rename of cn=ldaptestcontainer," + base_dn + " to cn=ldaptestcontainer2," + base_dn
+ ok = ldb.rename("CN=ldaptestcontainer," + base_dn, "CN=ldaptestcontainer2," + base_dn)
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ print "Testing ldb.search for (&(cn=ldaptestuser4)(objectClass=user))"
+ res = ldb.search("(&(cn=ldaptestuser4)(objectClass=user))")
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (&(cn=ldaptestuser4)(objectClass=user))"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+
+ print "Testing subtree ldb.search for (&(cn=ldaptestuser4)(objectClass=user)) in (just renamed from) cn=ldaptestcontainer," + base_dn
+ res = ldb.search("(&(cn=ldaptestuser4)(objectClass=user))", "cn=ldaptestcontainer," + base_dn, ldb.SCOPE_SUBTREE)
+ if (res.error != 32) {
+ print res.errstr
+ assertEquals(res.error, 32)
+ }
+
+ print "Testing one-level ldb.search for (&(cn=ldaptestuser4)(objectClass=user)) in (just renamed from) cn=ldaptestcontainer," + base_dn
+ res = ldb.search("(&(cn=ldaptestuser4)(objectClass=user))", "cn=ldaptestcontainer," + base_dn, ldb.SCOPE_ONELEVEL)
+ if (res.error != 32) {
+ print res.errstr
+ assertEquals(res.error, 32)
+ }
+
+ print "Testing ldb.search for (&(cn=ldaptestuser4)(objectClass=user)) in renamed container"
+ res = ldb.search("(&(cn=ldaptestuser4)(objectClass=user))", "cn=ldaptestcontainer2," + base_dn, ldb.SCOPE_SUBTREE)
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (&(cn=ldaptestuser4)(objectClass=user)) under cn=ldaptestcontainer2," + base_dn
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+
+ assertEquals(res[0].dn, ("CN=ldaptestuser4,CN=ldaptestcontainer2," + base_dn))
+ assertEquals(strupper(res[0].memberOf[0]), strupper(("CN=ldaptestgroup2,CN=Users," + base_dn)))
+
+ print "Testing ldb.search for (&(member=CN=ldaptestuser4,CN=ldaptestcontainer2," + base_dn + ")(objectclass=group)) to check subtree renames and linked attributes"
+ res = ldb.search("(&(member=CN=ldaptestuser4,CN=ldaptestcontainer2," + base_dn + ")(objectclass=group))", base_dn, ldb.SCOPE_SUBTREE)
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (&(member=CN=ldaptestuser4,CN=ldaptestcontainer2," + base_dn + ")(objectclass=group)), perhaps linked attributes are not conistant with subtree renames?"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+
+ print "Testing ldb.rename (into itself) of cn=ldaptestcontainer2," + base_dn + " to cn=ldaptestcontainer,cn=ldaptestcontainer2," + base_dn
+ ok = ldb.rename("cn=ldaptestcontainer2," + base_dn, "cn=ldaptestcontainer,cn=ldaptestcontainer2," + base_dn)
+ if (ok.error != 53) { # LDAP_UNWILLING_TO_PERFORM
+ print ok.errstr
+ assertEquals(ok.error, 53)
+ }
+
+ print "Testing ldb.rename (into non-existent container) of cn=ldaptestcontainer2," + base_dn + " to cn=ldaptestcontainer,cn=ldaptestcontainer3," + base_dn
+ ok = ldb.rename("cn=ldaptestcontainer2," + base_dn, "cn=ldaptestcontainer,cn=ldaptestcontainer3," + base_dn)
+ if (ok.error != 53 && ok.error != 80) { # LDAP_UNWILLING_TO_PERFORM or LDAP_OTHER
+ print ok.errstr
+ assertEquals(ok.error == 53 || ok.error, 80)
+ }
+
+ print "Testing delete (should fail, not a leaf node) of renamed cn=ldaptestcontainer2," + base_dn
+ ok = ldb.delete("cn=ldaptestcontainer2," + base_dn)
+ if (ok.error != 66) { # LDB_ERR_NOT_ALLOWED_ON_NON_LEAF
+ print ok.errstr
+ assertEquals(ok.error, 66)
+ }
+
+ print "Testing base ldb.search for CN=ldaptestuser4,CN=ldaptestcontainer2," + base_dn
+ res = ldb.search("(objectclass=*)", ("CN=ldaptestuser4,CN=ldaptestcontainer2," + base_dn), ldb.SCOPE_BASE)
+ if (res.error == 0 && res.count == 1) {
+ assertEquals(res.error == 0 && res.count, 1)
+ }
+ res = ldb.search("(cn=ldaptestuser40)", ("CN=ldaptestuser4,CN=ldaptestcontainer2," + base_dn), ldb.SCOPE_BASE)
+ if (res.error == 0 && res.count == 0) {
+ assertEquals(res.error == 0 && res.count, 0)
+ }
+
+ print "Testing one-level ldb.search for (&(cn=ldaptestuser4)(objectClass=user)) in cn=ldaptestcontainer2," + base_dn
+ res = ldb.search("(&(cn=ldaptestuser4)(objectClass=user))", "cn=ldaptestcontainer2," + base_dn, ldb.SCOPE_ONELEVEL)
+ if (res.error == 0 && res.count == 0) {
+ assertEquals(res.error == 0 && res.count, 0)
+ }
+
+ print "Testing one-level ldb.search for (&(cn=ldaptestuser4)(objectClass=user)) in cn=ldaptestcontainer2," + base_dn
+ res = ldb.search("(&(cn=ldaptestuser4)(objectClass=user))", "cn=ldaptestcontainer2," + base_dn, ldb.SCOPE_SUBTREE)
+ if (res.error == 0 && res.count == 0) {
+ assertEquals(res.error == 0 && res.count, 0)
+ }
+
+ print "Testing delete of subtree renamed "+("CN=ldaptestuser4,CN=ldaptestcontainer2," + base_dn)
+ ok = ldb.delete(("CN=ldaptestuser4,CN=ldaptestcontainer2," + base_dn))
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+ print "Testing delete of renamed cn=ldaptestcontainer2," + base_dn
+ ok = ldb.delete("cn=ldaptestcontainer2," + base_dn)
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ ok = ldb.add({"dn": "cn=ldaptestutf8user èùéìòà ,cn=users," + base_dn, "objectClass": "user"})
+ if (ok.error != 0) {
+ ok = ldb.delete("cn=ldaptestutf8user èùéìòà ,cn=users," + base_dn)
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+ ok = ldb.add({"dn": "cn=ldaptestutf8user èùéìòà ,cn=users," + base_dn, "objectClass": "user"})
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+ }
+
+ ok = ldb.add({"dn": "cn=ldaptestutf8user2 èùéìòà ,cn=users," + base_dn, "objectClass": "user"})
+ if (ok.error != 0) {
+ ok = ldb.delete("cn=ldaptestutf8user2 èùéìòà ,cn=users," + base_dn)
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+ ok = ldb.add({"dn": "cn=ldaptestutf8user2 èùéìòà ,cn=users," + base_dn,
+ "objectClass": "user"})
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+ }
+
+ print "Testing ldb.search for (&(cn=ldaptestuser)(objectClass=user))"
+ res = ldb.search("(&(cn=ldaptestuser)(objectClass=user))")
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (&(cn=ldaptestuser)(objectClass=user))"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+
+ assertEquals(res[0].dn, ("CN=ldaptestuser,CN=Users," + base_dn))
+ assertEquals(res[0].cn, "ldaptestuser")
+ assertEquals(res[0].name, "ldaptestuser")
+ assertEquals(res[0].objectClass[0], "top")
+ assertEquals(res[0].objectClass[1], "person")
+ assertEquals(res[0].objectClass[2], "organizationalPerson")
+ assertEquals(res[0].objectClass[3], "user")
+ assert(res[0].objectGUID != undefined)
+ assert(res[0].whenCreated != undefined)
+ assertEquals(res[0].objectCategory, ("CN=Person,CN=Schema,CN=Configuration," + base_dn))
+ assertEquals(res[0].sAMAccountType, 805306368)
+# assertEquals(res[0].userAccountControl, 546)
+ assertEquals(res[0].memberOf[0], ("CN=ldaptestgroup2,CN=Users," + base_dn))
+ assertEquals(res[0].memberOf.length, 1)
+
+ print "Testing ldb.search for (&(cn=ldaptestuser)(objectCategory=cn=person,cn=schema,cn=configuration," + base_dn + "))"
+ res2 = ldb.search("(&(cn=ldaptestuser)(objectCategory=cn=person,cn=schema,cn=configuration," + base_dn + "))")
+ if (res2.error != 0 || res2.msgs.length != 1) {
+ print "Could not find (&(cn=ldaptestuser)(objectCategory=cn=person,cn=schema,cn=configuration," + base_dn + "))"
+ assertEquals(res2.error, 0)
+ assertEquals(res2.msgs.length, 1)
+ }
+
+ assertEquals(res[0].dn, res2.msgs[0].dn)
+
+ print "Testing ldb.search for (&(cn=ldaptestuser)(objectCategory=PerSon))"
+ res3 = ldb.search("(&(cn=ldaptestuser)(objectCategory=PerSon))")
+ if (res3.error != 0) {
+ print "Could not find (&(cn=ldaptestuser)(objectCategory=PerSon)): " + res3.errstr
+ assertEquals(res3.error, 0)
+ } else if (res3.msgs.length != 1) {
+ print "Could not find (&(cn=ldaptestuser)(objectCategory=PerSon)): matched " + res3.msgs.length
+ assertEquals(res3.msgs.length, 1)
+ }
+
+ assertEquals(res[0].dn, res3.msgs[0].dn)
+
+ if (gc_ldb != undefined) {
+ print "Testing ldb.search for (&(cn=ldaptestuser)(objectCategory=PerSon)) in Global Catalog"
+ res3gc = gc_ldb.search("(&(cn=ldaptestuser)(objectCategory=PerSon))")
+ if (res3gc.error != 0) {
+ print "Could not find (&(cn=ldaptestuser)(objectCategory=PerSon)) in Global Catalog: " + res3gc.errstr
+ assertEquals(res3gc.error, 0)
+ } else if (res3gc.msgs.length != 1) {
+ print "Could not find (&(cn=ldaptestuser)(objectCategory=PerSon)) in Global Catalog: matched " + res3gc.msgs.length
+ assertEquals(res3gc.msgs.length, 1)
+ }
+
+ assertEquals(res[0].dn, res3gc.msgs[0].dn)
+ }
+
+ print "Testing ldb.search for (&(cn=ldaptestuser)(objectCategory=PerSon)) in with 'phantom root' control"
+ attrs = ["cn"]
+ controls = ["search_options:1:2"]
+ res3control = gc_ldb.search("(&(cn=ldaptestuser)(objectCategory=PerSon))", base_dn, ldb.SCOPE_SUBTREE, attrs, controls)
+ if (res3control.error != 0 || res3control.msgs.length != 1) {
+ print "Could not find (&(cn=ldaptestuser)(objectCategory=PerSon)) in Global Catalog"
+ assertEquals(res3control.error, 0)
+ assertEquals(res3control.msgs.length, 1)
+ }
+
+ assertEquals(res[0].dn, res3control.msgs[0].dn)
+
+ ok = ldb.delete(res[0].dn)
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ print "Testing ldb.search for (&(cn=ldaptestcomputer)(objectClass=user))"
+ res = ldb.search("(&(cn=ldaptestcomputer)(objectClass=user))")
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (&(cn=ldaptestuser)(objectClass=user))"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+
+ assertEquals(res[0].dn, ("CN=ldaptestcomputer,CN=Computers," + base_dn))
+ assertEquals(res[0].cn, "ldaptestcomputer")
+ assertEquals(res[0].name, "ldaptestcomputer")
+ assertEquals(res[0].objectClass[0], "top")
+ assertEquals(res[0].objectClass[1], "person")
+ assertEquals(res[0].objectClass[2], "organizationalPerson")
+ assertEquals(res[0].objectClass[3], "user")
+ assertEquals(res[0].objectClass[4], "computer")
+ assert(res[0].objectGUID != undefined)
+ assert(res[0].whenCreated != undefined)
+ assertEquals(res[0].objectCategory, ("CN=Computer,CN=Schema,CN=Configuration," + base_dn))
+ assertEquals(res[0].primaryGroupID, 513)
+# assertEquals(res[0].sAMAccountType, 805306368)
+# assertEquals(res[0].userAccountControl, 546)
+ assertEquals(res[0].memberOf[0], ("CN=ldaptestgroup2,CN=Users," + base_dn))
+ assertEquals(res[0].memberOf.length, 1)
+
+ print "Testing ldb.search for (&(cn=ldaptestcomputer)(objectCategory=cn=computer,cn=schema,cn=configuration," + base_dn + "))"
+ res2 = ldb.search("(&(cn=ldaptestcomputer)(objectCategory=cn=computer,cn=schema,cn=configuration," + base_dn + "))")
+ if (res2.error != 0 || res2.msgs.length != 1) {
+ print "Could not find (&(cn=ldaptestcomputer)(objectCategory=cn=computer,cn=schema,cn=configuration," + base_dn + "))"
+ assertEquals(res2.error, 0)
+ assertEquals(res2.msgs.length, 1)
+ }
+
+ assertEquals(res[0].dn, res2.msgs[0].dn)
+
+ if (gc_ldb != undefined) {
+ print "Testing ldb.search for (&(cn=ldaptestcomputer)(objectCategory=cn=computer,cn=schema,cn=configuration," + base_dn + ")) in Global Catlog"
+ res2gc = gc_ldb.search("(&(cn=ldaptestcomputer)(objectCategory=cn=computer,cn=schema,cn=configuration," + base_dn + "))")
+ if (res2gc.error != 0 || res2gc.msgs.length != 1) {
+ print "Could not find (&(cn=ldaptestcomputer)(objectCategory=cn=computer,cn=schema,cn=configuration," + base_dn + ")) in Global Catlog"
+ assertEquals(res2gc.error, 0)
+ assertEquals(res2gc.msgs.length, 1)
+ }
+
+ assertEquals(res[0].dn, res2gc.msgs[0].dn)
+ }
+
+ print "Testing ldb.search for (&(cn=ldaptestcomputer)(objectCategory=compuTER))"
+ res3 = ldb.search("(&(cn=ldaptestcomputer)(objectCategory=compuTER))")
+ if (res3.error != 0 || res3.msgs.length != 1) {
+ print "Could not find (&(cn=ldaptestcomputer)(objectCategory=compuTER))"
+ assertEquals(res3.error, 0)
+ assertEquals(res3.msgs.length, 1)
+ }
+
+ assertEquals(res[0].dn, res3.msgs[0].dn)
+
+ if (gc_ldb != undefined) {
+ print "Testing ldb.search for (&(cn=ldaptestcomputer)(objectCategory=compuTER)) in Global Catalog"
+ res3gc = gc_ldb.search("(&(cn=ldaptestcomputer)(objectCategory=compuTER))")
+ if (res3gc.error != 0 || res3gc.msgs.length != 1) {
+ print "Could not find (&(cn=ldaptestcomputer)(objectCategory=compuTER)) in Global Catalog"
+ assertEquals(res3gc.error, 0)
+ assertEquals(res3gc.msgs.length, 1)
+ }
+
+ assertEquals(res[0].dn, res3gc.msgs[0].dn)
+ }
+
+ print "Testing ldb.search for (&(cn=ldaptestcomp*r)(objectCategory=compuTER))"
+ res4 = ldb.search("(&(cn=ldaptestcomp*r)(objectCategory=compuTER))")
+ if (res4.error != 0 || res4.msgs.length != 1) {
+ print "Could not find (&(cn=ldaptestcomp*r)(objectCategory=compuTER))"
+ assertEquals(res4.error, 0)
+ assertEquals(res4.msgs.length, 1)
+ }
+
+ assertEquals(res[0].dn, res4.msgs[0].dn)
+
+ print "Testing ldb.search for (&(cn=ldaptestcomput*)(objectCategory=compuTER))"
+ res5 = ldb.search("(&(cn=ldaptestcomput*)(objectCategory=compuTER))")
+ if (res5.error != 0 || res5.msgs.length != 1) {
+ print "Could not find (&(cn=ldaptestcomput*)(objectCategory=compuTER))"
+ assertEquals(res5.error, 0)
+ assertEquals(res5.msgs.length, 1)
+ }
+
+ assertEquals(res[0].dn, res5.msgs[0].dn)
+
+ print "Testing ldb.search for (&(cn=*daptestcomputer)(objectCategory=compuTER))"
+ res6 = ldb.search("(&(cn=*daptestcomputer)(objectCategory=compuTER))")
+ if (res6.error != 0 || res6.msgs.length != 1) {
+ print "Could not find (&(cn=*daptestcomputer)(objectCategory=compuTER))"
+ assertEquals(res6.error, 0)
+ assertEquals(res6.msgs.length, 1)
+ }
+
+ assertEquals(res[0].dn, res6.msgs[0].dn)
+
+ ok = ldb.delete(res[0].dn)
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ print "Testing ldb.search for (&(cn=ldaptest2computer)(objectClass=user))"
+ res = ldb.search("(&(cn=ldaptest2computer)(objectClass=user))")
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (&(cn=ldaptest2computer)(objectClass=user))"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+
+ assertEquals(res[0].dn, ("CN=ldaptest2computer,CN=Computers," + base_dn))
+ assertEquals(res[0].cn, "ldaptest2computer")
+ assertEquals(res[0].name, "ldaptest2computer")
+ assertEquals(res[0].objectClass[0], "top")
+ assertEquals(res[0].objectClass[1], "person")
+ assertEquals(res[0].objectClass[2], "organizationalPerson")
+ assertEquals(res[0].objectClass[3], "user")
+ assertEquals(res[0].objectClass[4], "computer")
+ assert(res[0].objectGUID != undefined)
+ assert(res[0].whenCreated != undefined)
+ assertEquals(res[0].objectCategory, "cn=Computer,cn=Schema,cn=Configuration," + base_dn)
+ assertEquals(res[0].sAMAccountType, 805306369)
+# assertEquals(res[0].userAccountControl, 4098)
+
+ ok = ldb.delete(res[0].dn)
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ attrs = ["cn", "name", "objectClass", "objectGUID", "whenCreated", "nTSecurityDescriptor", "memberOf"]
+ print "Testing ldb.search for (&(cn=ldaptestUSer2)(objectClass=user))"
+ res = ldb.search(base_dn, "(&(cn=ldaptestUSer2)(objectClass=user))", ldb.SCOPE_SUBTREE, attrs)
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (&(cn=ldaptestUSer2)(objectClass=user))"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+
+ assertEquals(res[0].dn, ("CN=ldaptestuser2,CN=Users," + base_dn))
+ assertEquals(res[0].cn, "ldaptestuser2")
+ assertEquals(res[0].name, "ldaptestuser2")
+ assertEquals(res[0].objectClass[0], "top")
+ assertEquals(res[0].objectClass[1], "person")
+ assertEquals(res[0].objectClass[2], "organizationalPerson")
+ assertEquals(res[0].objectClass[3], "user")
+ assert(res[0].objectGUID != undefined)
+ assert(res[0].whenCreated != undefined)
+ assert(res[0].nTSecurityDescriptor != undefined)
+ assertEquals(res[0].memberOf[0], ("CN=ldaptestgroup2,CN=Users," + base_dn))
+
+ attrs = ["cn", "name", "objectClass", "objectGUID", "whenCreated", "nTSecurityDescriptor", "member"]
+ print "Testing ldb.search for (&(cn=ldaptestgroup2)(objectClass=group))"
+ res = ldb.search("(&(cn=ldaptestgroup2)(objectClass=group))", base_dn, ldb.SCOPE_SUBTREE, attrs)
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (&(cn=ldaptestgroup2)(objectClass=group))"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+
+ assertEquals(res[0].dn, ("CN=ldaptestgroup2,CN=Users," + base_dn))
+ assertEquals(res[0].cn, "ldaptestgroup2")
+ assertEquals(res[0].name, "ldaptestgroup2")
+ assertEquals(res[0].objectClass[0], "top")
+ assertEquals(res[0].objectClass[1], "group")
+ assert(res[0].objectGUID != undefined)
+ assert(res[0].whenCreated != undefined)
+ assert(res[0].nTSecurityDescriptor != undefined)
+ assertEquals(res[0].member[0], ("CN=ldaptestuser2,CN=Users," + base_dn))
+ assertEquals(res[0].member.length, 1)
+
+ ok = ldb.modify("
+dn: cn=ldaptestgroup2,cn=users," + base_dn + "
+changetype: modify
+replace: member
+member: CN=ldaptestuser2,CN=Users," + base_dn + "
+member: CN=ldaptestutf8user èùéìòà,CN=Users," + base_dn + "
+")
+ if (ok.error != 0) {
+ print "Failure testing replace of linked attributes"
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ print "Testing Linked attribute behaviours"
+ ok = ldb.modify("
+dn: cn=ldaptestgroup2,cn=users," + base_dn + "
+changetype: modify
+delete: member
+")
+ if (ok.error != 0) {
+ print "Failure testing delete of linked attributes"
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ ok = ldb.modify("
+dn: cn=ldaptestgroup2,cn=users," + base_dn + "
+changetype: modify
+add: member
+member: CN=ldaptestuser2,CN=Users," + base_dn + "
+member: CN=ldaptestutf8user èùéìòà,CN=Users," + base_dn + "
+")
+ if (ok.error != 0) {
+ print "Failure testing add of linked attributes"
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ ok = ldb.modify("
+dn: cn=ldaptestgroup2,cn=users," + base_dn + "
+changetype: modify
+replace: member
+")
+ if (ok.error != 0) {
+ print "Failure testing replace of linked attributes"
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ ok = ldb.modify("
+dn: cn=ldaptestgroup2,cn=users," + base_dn + "
+changetype: modify
+add: member
+member: CN=ldaptestuser2,CN=Users," + base_dn + "
+member: CN=ldaptestutf8user èùéìòà,CN=Users," + base_dn + "
+")
+ if (ok.error != 0) {
+ print "Failure testing add of linked attributes"
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ ok = ldb.modify("
+dn: cn=ldaptestgroup2,cn=users," + base_dn + "
+changetype: modify
+delete: member
+member: CN=ldaptestutf8user èùéìòà,CN=Users," + base_dn + "
+")
+ if (ok.error != 0) {
+ print "Failure testing replace of linked attributes"
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ res = ldb.search("(&(cn=ldaptestgroup2)(objectClass=group))", base_dn, ldb.SCOPE_SUBTREE, attrs)
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (&(cn=ldaptestgroup2)(objectClass=group))"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+
+ assertEquals(res[0].dn, ("CN=ldaptestgroup2,CN=Users," + base_dn))
+ assertEquals(res[0].member[0], ("CN=ldaptestuser2,CN=Users," + base_dn))
+ assertEquals(res[0].member.length, 1)
+
+ ok = ldb.delete(("CN=ldaptestuser2,CN=Users," + base_dn))
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ attrs = ["cn", "name", "objectClass", "objectGUID", "whenCreated", "nTSecurityDescriptor", "member"]
+ print "Testing ldb.search for (&(cn=ldaptestgroup2)(objectClass=group)) to check linked delete"
+ res = ldb.search("(&(cn=ldaptestgroup2)(objectClass=group))", base_dn, ldb.SCOPE_SUBTREE, attrs)
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (&(cn=ldaptestgroup2)(objectClass=group)) to check linked delete"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+
+ assertEquals(res[0].dn, ("CN=ldaptestgroup2,CN=Users," + base_dn))
+ assertEquals(res[0].member, undefined)
+
+ print "Testing ldb.search for (&(cn=ldaptestutf8user ÈÙÉÌÒÀ)(objectClass=user))"
+ res = ldb.search("(&(cn=ldaptestutf8user ÈÙÉÌÒÀ)(objectClass=user))")
+
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (&(cn=ldaptestutf8user ÈÙÉÌÒÀ)(objectClass=user))"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+
+ assertEquals(res[0].dn, ("CN=ldaptestutf8user èùéìòà,CN=Users," + base_dn))
+ assertEquals(res[0].cn, "ldaptestutf8user èùéìòà")
+ assertEquals(res[0].name, "ldaptestutf8user èùéìòà")
+ assertEquals(res[0].objectClass[0], "top")
+ assertEquals(res[0].objectClass[1], "person")
+ assertEquals(res[0].objectClass[2], "organizationalPerson")
+ assertEquals(res[0].objectClass[3], "user")
+ assert(res[0].objectGUID != undefined)
+ assert(res[0].whenCreated != undefined)
+
+ ok = ldb.delete(res[0].dn)
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ print "Testing ldb.search for (&(cn=ldaptestutf8user2*)(objectClass=user))"
+ res = ldb.search("(&(cn=ldaptestutf8user2*)(objectClass=user))")
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (&(cn=ldaptestutf8user2*)(objectClass=user))"
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ }
+
+ ok = ldb.delete(res[0].dn)
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ ok = ldb.delete(("CN=ldaptestgroup2,CN=Users," + base_dn))
+ if (ok.error != 0) {
+ print ok.errstr
+ assertEquals(ok.error, 0)
+ }
+
+ print "Testing ldb.search for (&(cn=ldaptestutf8user2 ÈÙÉÌÒÀ)(objectClass=user))"
+ res = ldb.search("(&(cn=ldaptestutf8user ÈÙÉÌÒÀ)(objectClass=user))")
+
+ if (res.error != 0 || len(res) != 1) {
+ print "Could not find (expect space collapse, win2k3 fails) (&(cn=ldaptestutf8user2 ÈÙÉÌÒÀ)(objectClass=user))"
+ } else {
+ assertEquals(res[0].dn, ("cn=ldaptestutf8user2 èùéìòà,cn=users," + base_dn))
+ assertEquals(res[0].cn, "ldaptestutf8user2 èùéìòà")
+ }
+
+ print "Testing that we can't get at the configuration DN from the main search base"
+ attrs = ["cn"]
+ res = ldb.search("objectClass=crossRef", base_dn, ldb.SCOPE_SUBTREE, attrs)
+ assertEquals(res.error, 0)
+ if (len(res) != 0) {
+ print "Got configuration DN " + res[0].dn + " which should not be able to be seen from main search base"
+ }
+ assertEquals(len(res), 0)
+
+ print "Testing that we can get at the configuration DN from the main search base on the LDAP port with the 'phantom root' search_options control"
+ attrs = ["cn"]
+ controls = ["search_options:1:2"]
+ res = ldb.search("objectClass=crossRef", base_dn, ldb.SCOPE_SUBTREE, attrs, controls)
+ assertEquals(res.error, 0)
+ assert(len(res) > 0)
+
+ if (gc_ldb != undefined) {
+ print "Testing that we can get at the configuration DN from the main search base on the GC port with the search_options control == 0"
+ attrs = ["cn"]
+ controls = ["search_options:1:0"]
+ res = gc_ldb.search("objectClass=crossRef", base_dn, gc_ldb.SCOPE_SUBTREE, attrs, controls)
+ assertEquals(res.error, 0)
+ assert(len(res) > 0)
+
+ print "Testing that we do find configuration elements in the global catlog"
+ attrs = ["cn"]
+ res = gc_ldb.search("objectClass=crossRef", base_dn, ldb.SCOPE_SUBTREE, attrs)
+ assertEquals(res.error, 0)
+ assert (len(res) > 0)
+
+ print "Testing that we do find configuration elements and user elements at the same time"
+ attrs = ["cn"]
+ res = gc_ldb.search("(|(objectClass=crossRef)(objectClass=person))", base_dn, ldb.SCOPE_SUBTREE, attrs)
+ assertEquals(res.error, 0)
+ assert (len(res) > 0)
+
+ print "Testing that we do find configuration elements in the global catlog, with the configuration basedn"
+ attrs = ["cn"]
+ res = gc_ldb.search("objectClass=crossRef", configuration_dn, ldb.SCOPE_SUBTREE, attrs)
+ assertEquals(res.error, 0)
+ assert (len(res) > 0)
+ }
+
+ print "Testing that we can get at the configuration DN on the main LDAP port"
+ attrs = ["cn"]
+ res = ldb.search("objectClass=crossRef", configuration_dn, ldb.SCOPE_SUBTREE, attrs)
+ assertEquals(res.error, 0)
+ assert (len(res) > 0)
+
+ print "Testing objectCategory canonacolisation"
+ attrs = ["cn"]
+ res = ldb.search("objectCategory=ntDsDSA", configuration_dn, ldb.SCOPE_SUBTREE, attrs)
+ assertEquals(res.error, 0)
+ if (len(res) == 0) {
+ print "Didn't find any records with objectCategory=ntDsDSA"
+ }
+ assert(len(res) != 0)
+
+ attrs = ["cn"]
+ res = ldb.search("objectCategory=CN=ntDs-DSA," + schema_dn, configuration_dn, ldb.SCOPE_SUBTREE, attrs)
+ assertEquals(res.error, 0)
+ if (len(res) == 0) {
+ print "Didn't find any records with objectCategory=CN=ntDs-DSA," + schema_dn
+ }
+ assert(len(res) != 0)
+
+ print "Testing objectClass attribute order on "+ base_dn
+ attrs = ["objectClass"]
+ res = ldb.search("objectClass=domain", base_dn, ldb.SCOPE_BASE, attrs)
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+
+ assertEquals(res[0].objectClass[0], "top")
+ assertEquals(res[0].objectClass[1], "domain")
+ assertEquals(res[0].objectClass[2], "domainDNS")
+
+# check enumeration
+
+ attrs = ["cn"]
+ print "Testing ldb.search for objectCategory=person"
+ res = ldb.search("objectCategory=person", base_dn, ldb.SCOPE_SUBTREE, attrs)
+ assertEquals(res.error, 0)
+ assert(len(res) > 0)
+
+ attrs = ["cn"]
+ controls = ["domain_scope:1"]
+ print "Testing ldb.search for objectCategory=person with domain scope control"
+ res = ldb.search("objectCategory=person", base_dn, ldb.SCOPE_SUBTREE, attrs, controls)
+ assertEquals(res.error, 0)
+ assert(len(res) > 0)
+
+ attrs = ["cn"]
+ print "Testing ldb.search for objectCategory=user"
+ res = ldb.search("objectCategory=user", base_dn, ldb.SCOPE_SUBTREE, attrs)
+ assertEquals(res.error, 0)
+ assert(len(res) > 0)
+
+ attrs = ["cn"]
+ controls = ["domain_scope:1"]
+ print "Testing ldb.search for objectCategory=user with domain scope control"
+ res = ldb.search("objectCategory=user", base_dn, ldb.SCOPE_SUBTREE, attrs, controls)
+ assertEquals(res.error, 0)
+ assert(len(res) > 0)
+
+ attrs = ["cn"]
+ print "Testing ldb.search for objectCategory=group"
+ res = ldb.search("objectCategory=group", base_dn, ldb.SCOPE_SUBTREE, attrs)
+ assertEquals(res.error, 0)
+ assert(len(res) > 0)
+
+ attrs = ["cn"]
+ controls = ["domain_scope:1"]
+ print "Testing ldb.search for objectCategory=group with domain scope control"
+ res = ldb.search("objectCategory=group", base_dn, ldb.SCOPE_SUBTREE, attrs, controls)
+ assertEquals(res.error, 0)
+ assert(len(res) > 0)
+
+}
+
+def basedn_tests(ldb, gc_ldb):
+ print "Testing for all rootDSE attributes"
+ attrs = []
+ res = ldb.search("", "", ldb.SCOPE_BASE, attrs)
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+
+ print "Testing for highestCommittedUSN"
+ attrs = ["highestCommittedUSN"]
+ res = ldb.search("", "", ldb.SCOPE_BASE, attrs)
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ assert(res[0].highestCommittedUSN != undefined)
+ assert(res[0].highestCommittedUSN != 0)
+
+ print "Testing for netlogon via LDAP"
+ attrs = ["netlogon"]
+ res = ldb.search("", "", ldb.SCOPE_BASE, attrs)
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 0)
+
+ print "Testing for netlogon and highestCommittedUSN via LDAP"
+ attrs = ["netlogon", "highestCommittedUSN"]
+ res = ldb.search("", "", ldb.SCOPE_BASE, attrs)
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 0)
+
+def find_basedn(ldb):
+ attrs = ["defaultNamingContext"]
+ res = ldb.search("", "", ldb.SCOPE_BASE, attrs)
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ return res[0].defaultNamingContext
+
+def find_configurationdn(ldb):
+ attrs = ["configurationNamingContext"]
+ res = ldb.search("", "", ldb.SCOPE_BASE, attrs)
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ return res[0].configurationNamingContext
+
+def find_schemadn(ldb):
+ res = ldb.search("", "", ldb.SCOPE_BASE, attrs=["schemaNamingContext"])
+ assertEquals(res.error, 0)
+ assertEquals(len(res), 1)
+ return res[0].schemaNamingContext
+
+# use command line creds if available
+ldb.credentials = options.get_credentials()
+gc_ldb.credentials = options.get_credentials()
+
+ok = ldb.connect("ldap://" + host)
+base_dn = find_basedn(ldb)
+
+configuration_dn = find_configurationdn(ldb)
+schema_dn = find_schemadn(ldb)
+
+print "baseDN: %s\n" % base_dn
+
+ok = gc_ldb.connect("ldap://" + host + ":3268")
+if (!ok) {
+ gc_ldb = undefined
+}
+
+basic_tests(ldb, gc_ldb, base_dn, configuration_dn, schema_dn)
+basedn_tests(ldb, gc_ldb)
diff --git a/source4/lib/registry/registry.i b/source4/lib/registry/registry.i
index 3fabba9a66..6f46e081c2 100644
--- a/source4/lib/registry/registry.i
+++ b/source4/lib/registry/registry.i
@@ -32,7 +32,7 @@ typedef struct hive_key hive_key;
%}
/* FIXME: This should be in another file */
-%typemap(default) struct auth_session_info * {
+%typemap(default,noblock=1) struct auth_session_info * {
$1 = NULL;
}
@@ -48,11 +48,11 @@ const char *reg_get_predef_name(uint32_t hkey);
const char *str_regtype(int type);
/* Registry contexts */
-%typemap(in,numinputs=0) struct registry_context ** (struct registry_context *tmp) {
+%typemap(in,noblock=1,numinputs=0) struct registry_context ** (struct registry_context *tmp) {
$1 = &tmp;
}
-%typemap(argout) struct registry_context ** {
+%typemap(argout,noblock=1) struct registry_context ** {
$result = SWIG_NewPointerObj(*$1, SWIGTYPE_p_registry_context, 0);
}
@@ -61,7 +61,7 @@ WERROR reg_open_local(TALLOC_CTX *parent_ctx, struct registry_context **ctx,
struct auth_session_info *session_info,
struct cli_credentials *credentials);
-%typemap(in) const char ** {
+%typemap(in,noblock=1) const char ** {
/* Check if is a list */
if (PyList_Check($input)) {
int size = PyList_Size($input);
@@ -84,7 +84,7 @@ WERROR reg_open_local(TALLOC_CTX *parent_ctx, struct registry_context **ctx,
}
}
-%typemap(freearg) const char ** {
+%typemap(freearg,noblock=1) const char ** {
free((char **) $1);
}
@@ -121,11 +121,11 @@ typedef struct registry_context {
} reg;
/* Hives */
-%typemap(in,numinputs=0) struct hive_key ** (struct hive_key *tmp) {
+%typemap(in,noblock=1,numinputs=0) struct hive_key ** (struct hive_key *tmp) {
$1 = &tmp;
}
-%typemap(argout) struct hive_key ** {
+%typemap(argout,noblock=1) struct hive_key ** {
Py_XDECREF($result);
$result = SWIG_NewPointerObj(*$1, SWIGTYPE_p_hive_key, 0);
}
diff --git a/source4/lib/registry/registry_wrap.c b/source4/lib/registry/registry_wrap.c
index c02f9cacc6..cabdfad887 100644
--- a/source4/lib/registry/registry_wrap.c
+++ b/source4/lib/registry/registry_wrap.c
@@ -2928,18 +2928,12 @@ SWIGINTERN PyObject *_wrap_Registry(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
(char *) "session_info",(char *) "credentials", NULL
};
- {
- arg3 = NULL;
- }
+ arg3 = NULL;
{
arg4 = NULL;
}
- {
- arg1 = NULL;
- }
- {
- arg2 = &tmp2;
- }
+ arg1 = NULL;
+ arg2 = &tmp2;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:Registry",kwnames,&obj0,&obj1)) SWIG_fail;
if (obj0) {
res3 = SWIG_ConvertPtr(obj0, &argp3,SWIGTYPE_p_auth_session_info, 0 | 0 );
@@ -2956,17 +2950,14 @@ SWIGINTERN PyObject *_wrap_Registry(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
arg4 = (struct cli_credentials *)(argp4);
}
result = reg_open_local(arg1,arg2,arg3,arg4);
- {
- if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- }
- {
- resultobj = SWIG_NewPointerObj(*arg2, SWIGTYPE_p_registry_context, 0);
- }
+ if (!W_ERROR_IS_OK(result)) {
+ PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
+ PyErr_SetObject(PyExc_RuntimeError, obj);
+ SWIG_fail;
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
+ }
+ resultobj = SWIG_NewPointerObj(*arg2, SWIGTYPE_p_registry_context, 0);
return resultobj;
fail:
return NULL;
@@ -3010,13 +3001,12 @@ SWIGINTERN PyObject *_wrap_reg_get_predefined_key_by_name(PyObject *SWIGUNUSEDPA
}
arg3 = (struct registry_key **)(argp3);
result = reg_get_predefined_key_by_name(arg1,(char const *)arg2,arg3);
- {
- if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
+ if (!W_ERROR_IS_OK(result)) {
+ PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
+ PyErr_SetObject(PyExc_RuntimeError, obj);
+ SWIG_fail;
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
}
if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
return resultobj;
@@ -3054,13 +3044,12 @@ SWIGINTERN PyObject *_wrap_reg_key_del_abs(PyObject *SWIGUNUSEDPARM(self), PyObj
}
arg2 = (char *)(buf2);
result = reg_key_del_abs(arg1,(char const *)arg2);
- {
- if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
+ if (!W_ERROR_IS_OK(result)) {
+ PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
+ PyErr_SetObject(PyExc_RuntimeError, obj);
+ SWIG_fail;
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
}
if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
return resultobj;
@@ -3106,13 +3095,12 @@ SWIGINTERN PyObject *_wrap_reg_get_predefined_key(PyObject *SWIGUNUSEDPARM(self)
}
arg3 = (struct registry_key **)(argp3);
result = reg_get_predefined_key(arg1,arg2,arg3);
- {
- if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
+ if (!W_ERROR_IS_OK(result)) {
+ PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
+ PyErr_SetObject(PyExc_RuntimeError, obj);
+ SWIG_fail;
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
}
return resultobj;
fail:
@@ -3148,13 +3136,12 @@ SWIGINTERN PyObject *_wrap_reg_diff_apply(PyObject *SWIGUNUSEDPARM(self), PyObje
}
arg2 = (char *)(buf2);
result = reg_diff_apply(arg1,(char const *)arg2);
- {
- if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
+ if (!W_ERROR_IS_OK(result)) {
+ PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
+ PyErr_SetObject(PyExc_RuntimeError, obj);
+ SWIG_fail;
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
}
if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
return resultobj;
@@ -3207,13 +3194,12 @@ SWIGINTERN PyObject *_wrap_reg_generate_diff(PyObject *SWIGUNUSEDPARM(self), PyO
SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "reg_generate_diff" "', argument " "4"" of type '" "void *""'");
}
result = reg_generate_diff(arg1,arg2,(struct reg_diff_callbacks const *)arg3,arg4);
- {
- if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
+ if (!W_ERROR_IS_OK(result)) {
+ PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
+ PyErr_SetObject(PyExc_RuntimeError, obj);
+ SWIG_fail;
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
}
return resultobj;
fail:
@@ -3252,46 +3238,39 @@ SWIGINTERN PyObject *_wrap_reg_mount_hive__SWIG_0(PyObject *SWIGUNUSEDPARM(self)
}
arg3 = (uint32_t)(val3);
if (swig_obj[3]) {
- {
- /* Check if is a list */
- if (PyList_Check(swig_obj[3])) {
- int size = PyList_Size(swig_obj[3]);
- int i = 0;
- arg4 = (char **) malloc((size+1)*sizeof(const char *));
- for (i = 0; i < size; i++) {
- PyObject *o = PyList_GetItem(swig_obj[3],i);
- if (PyString_Check(o))
- arg4[i] = PyString_AsString(PyList_GetItem(swig_obj[3],i));
- else {
- PyErr_SetString(PyExc_TypeError,"list must contain strings");
- free(arg4);
- return NULL;
- }
+ /* Check if is a list */
+ if (PyList_Check(swig_obj[3])) {
+ int size = PyList_Size(swig_obj[3]);
+ int i = 0;
+ arg4 = (char **) malloc((size+1)*sizeof(const char *));
+ for (i = 0; i < size; i++) {
+ PyObject *o = PyList_GetItem(swig_obj[3],i);
+ if (PyString_Check(o))
+ arg4[i] = PyString_AsString(PyList_GetItem(swig_obj[3],i));
+ else {
+ PyErr_SetString(PyExc_TypeError,"list must contain strings");
+ free(arg4);
+ return NULL;
}
- arg4[i] = 0;
- } else {
- PyErr_SetString(PyExc_TypeError,"not a list");
- return NULL;
}
+ arg4[i] = 0;
+ } else {
+ PyErr_SetString(PyExc_TypeError,"not a list");
+ return NULL;
}
}
result = reg_mount_hive(arg1,arg2,arg3,(char const **)arg4);
- {
- if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- }
- {
- free((char **) arg4);
- }
+ if (!W_ERROR_IS_OK(result)) {
+ PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
+ PyErr_SetObject(PyExc_RuntimeError, obj);
+ SWIG_fail;
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
+ }
+ free((char **) arg4);
return resultobj;
fail:
- {
- free((char **) arg4);
- }
+ free((char **) arg4);
return NULL;
}
@@ -3333,38 +3312,32 @@ SWIGINTERN PyObject *_wrap_reg_import_hive_key(PyObject *SWIGUNUSEDPARM(self), P
SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "reg_import_hive_key" "', argument " "3"" of type '" "uint32_t""'");
}
arg3 = (uint32_t)(val3);
- {
- /* Check if is a list */
- if (PyList_Check(obj3)) {
- int size = PyList_Size(obj3);
- int i = 0;
- arg4 = (char **) malloc((size+1)*sizeof(const char *));
- for (i = 0; i < size; i++) {
- PyObject *o = PyList_GetItem(obj3,i);
- if (PyString_Check(o))
- arg4[i] = PyString_AsString(PyList_GetItem(obj3,i));
- else {
- PyErr_SetString(PyExc_TypeError,"list must contain strings");
- free(arg4);
- return NULL;
- }
+ /* Check if is a list */
+ if (PyList_Check(obj3)) {
+ int size = PyList_Size(obj3);
+ int i = 0;
+ arg4 = (char **) malloc((size+1)*sizeof(const char *));
+ for (i = 0; i < size; i++) {
+ PyObject *o = PyList_GetItem(obj3,i);
+ if (PyString_Check(o))
+ arg4[i] = PyString_AsString(PyList_GetItem(obj3,i));
+ else {
+ PyErr_SetString(PyExc_TypeError,"list must contain strings");
+ free(arg4);
+ return NULL;
}
- arg4[i] = 0;
- } else {
- PyErr_SetString(PyExc_TypeError,"not a list");
- return NULL;
}
+ arg4[i] = 0;
+ } else {
+ PyErr_SetString(PyExc_TypeError,"not a list");
+ return NULL;
}
result = (struct registry_key *)reg_import_hive_key(arg1,arg2,arg3,(char const **)arg4);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_registry_key, 0 | 0 );
- {
- free((char **) arg4);
- }
+ free((char **) arg4);
return resultobj;
fail:
- {
- free((char **) arg4);
- }
+ free((char **) arg4);
return NULL;
}
@@ -3400,13 +3373,12 @@ SWIGINTERN PyObject *_wrap_reg_mount_hive__SWIG_1(PyObject *SWIGUNUSEDPARM(self)
}
arg3 = (char *)(buf3);
result = reg_mount_hive__SWIG_1(arg1,arg2,(char const *)arg3);
- {
- if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
+ if (!W_ERROR_IS_OK(result)) {
+ PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
+ PyErr_SetObject(PyExc_RuntimeError, obj);
+ SWIG_fail;
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
}
if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
return resultobj;
@@ -3519,21 +3491,15 @@ SWIGINTERN PyObject *_wrap_hive_key(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
(char *) "location",(char *) "session_info",(char *) "credentials",(char *) "lp_ctx", NULL
};
- {
- arg3 = NULL;
- }
+ arg3 = NULL;
{
arg4 = NULL;
}
{
arg5 = loadparm_init(NULL);
}
- {
- arg1 = NULL;
- }
- {
- arg6 = &tmp6;
- }
+ arg1 = NULL;
+ arg6 = &tmp6;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|OOO:hive_key",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
res2 = SWIG_AsCharPtrAndSize(obj0, &buf2, NULL, &alloc2);
if (!SWIG_IsOK(res2)) {
@@ -3562,18 +3528,15 @@ SWIGINTERN PyObject *_wrap_hive_key(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
arg5 = (struct loadparm_context *)(argp5);
}
result = reg_open_hive(arg1,(char const *)arg2,arg3,arg4,arg5,arg6);
- {
- if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- }
- {
- Py_XDECREF(resultobj);
- resultobj = SWIG_NewPointerObj(*arg6, SWIGTYPE_p_hive_key, 0);
- }
+ if (!W_ERROR_IS_OK(result)) {
+ PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
+ PyErr_SetObject(PyExc_RuntimeError, obj);
+ SWIG_fail;
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
+ }
+ Py_XDECREF(resultobj);
+ resultobj = SWIG_NewPointerObj(*arg6, SWIGTYPE_p_hive_key, 0);
if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
return resultobj;
fail:
@@ -3609,21 +3572,15 @@ SWIGINTERN PyObject *_wrap_open_ldb(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
(char *) "location",(char *) "session_info",(char *) "credentials",(char *) "lp_ctx", NULL
};
- {
- arg3 = NULL;
- }
+ arg3 = NULL;
{
arg4 = NULL;
}
{
arg5 = loadparm_init(NULL);
}
- {
- arg1 = NULL;
- }
- {
- arg6 = &tmp6;
- }
+ arg1 = NULL;
+ arg6 = &tmp6;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|OOO:open_ldb",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
res2 = SWIG_AsCharPtrAndSize(obj0, &buf2, NULL, &alloc2);
if (!SWIG_IsOK(res2)) {
@@ -3652,18 +3609,15 @@ SWIGINTERN PyObject *_wrap_open_ldb(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
arg5 = (struct loadparm_context *)(argp5);
}
result = reg_open_ldb_file(arg1,(char const *)arg2,arg3,arg4,arg5,arg6);
- {
- if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- }
- {
- Py_XDECREF(resultobj);
- resultobj = SWIG_NewPointerObj(*arg6, SWIGTYPE_p_hive_key, 0);
- }
+ if (!W_ERROR_IS_OK(result)) {
+ PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
+ PyErr_SetObject(PyExc_RuntimeError, obj);
+ SWIG_fail;
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
+ }
+ Py_XDECREF(resultobj);
+ resultobj = SWIG_NewPointerObj(*arg6, SWIGTYPE_p_hive_key, 0);
if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
return resultobj;
fail:
@@ -3687,12 +3641,8 @@ SWIGINTERN PyObject *_wrap_create_dir(PyObject *SWIGUNUSEDPARM(self), PyObject *
(char *) "location", NULL
};
- {
- arg1 = NULL;
- }
- {
- arg3 = &tmp3;
- }
+ arg1 = NULL;
+ arg3 = &tmp3;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:create_dir",kwnames,&obj0)) SWIG_fail;
res2 = SWIG_AsCharPtrAndSize(obj0, &buf2, NULL, &alloc2);
if (!SWIG_IsOK(res2)) {
@@ -3700,18 +3650,15 @@ SWIGINTERN PyObject *_wrap_create_dir(PyObject *SWIGUNUSEDPARM(self), PyObject *
}
arg2 = (char *)(buf2);
result = reg_create_directory(arg1,(char const *)arg2,arg3);
- {
- if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- }
- {
- Py_XDECREF(resultobj);
- resultobj = SWIG_NewPointerObj(*arg3, SWIGTYPE_p_hive_key, 0);
- }
+ if (!W_ERROR_IS_OK(result)) {
+ PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
+ PyErr_SetObject(PyExc_RuntimeError, obj);
+ SWIG_fail;
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
+ }
+ Py_XDECREF(resultobj);
+ resultobj = SWIG_NewPointerObj(*arg3, SWIGTYPE_p_hive_key, 0);
if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
return resultobj;
fail:
@@ -3735,12 +3682,8 @@ SWIGINTERN PyObject *_wrap_open_dir(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
(char *) "location", NULL
};
- {
- arg1 = NULL;
- }
- {
- arg3 = &tmp3;
- }
+ arg1 = NULL;
+ arg3 = &tmp3;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:open_dir",kwnames,&obj0)) SWIG_fail;
res2 = SWIG_AsCharPtrAndSize(obj0, &buf2, NULL, &alloc2);
if (!SWIG_IsOK(res2)) {
@@ -3748,18 +3691,15 @@ SWIGINTERN PyObject *_wrap_open_dir(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
}
arg2 = (char *)(buf2);
result = reg_open_directory(arg1,(char const *)arg2,arg3);
- {
- if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- }
- {
- Py_XDECREF(resultobj);
- resultobj = SWIG_NewPointerObj(*arg3, SWIGTYPE_p_hive_key, 0);
- }
+ if (!W_ERROR_IS_OK(result)) {
+ PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
+ PyErr_SetObject(PyExc_RuntimeError, obj);
+ SWIG_fail;
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
+ }
+ Py_XDECREF(resultobj);
+ resultobj = SWIG_NewPointerObj(*arg3, SWIGTYPE_p_hive_key, 0);
if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
return resultobj;
fail:
@@ -3793,18 +3733,12 @@ SWIGINTERN PyObject *_wrap_open_samba(PyObject *SWIGUNUSEDPARM(self), PyObject *
{
arg3 = loadparm_init(NULL);
}
- {
- arg4 = NULL;
- }
+ arg4 = NULL;
{
arg5 = NULL;
}
- {
- arg1 = NULL;
- }
- {
- arg2 = &tmp2;
- }
+ arg1 = NULL;
+ arg2 = &tmp2;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:open_samba",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
if (obj0) {
res3 = SWIG_ConvertPtr(obj0, &argp3,SWIGTYPE_p_loadparm_context, 0 | 0 );
@@ -3828,17 +3762,14 @@ SWIGINTERN PyObject *_wrap_open_samba(PyObject *SWIGUNUSEDPARM(self), PyObject *
arg5 = (struct cli_credentials *)(argp5);
}
result = reg_open_samba(arg1,arg2,arg3,arg4,arg5);
- {
- if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- }
- {
- resultobj = SWIG_NewPointerObj(*arg2, SWIGTYPE_p_registry_context, 0);
- }
+ if (!W_ERROR_IS_OK(result)) {
+ PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
+ PyErr_SetObject(PyExc_RuntimeError, obj);
+ SWIG_fail;
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
+ }
+ resultobj = SWIG_NewPointerObj(*arg2, SWIGTYPE_p_registry_context, 0);
return resultobj;
fail:
return NULL;
diff --git a/source4/lib/registry/tests/bindings.py b/source4/lib/registry/tests/bindings.py
index 9f93ee9382..906deed7e9 100644
--- a/source4/lib/registry/tests/bindings.py
+++ b/source4/lib/registry/tests/bindings.py
@@ -40,11 +40,11 @@ class HiveTests(samba.tests.TestCaseInTempDir):
def test_ldb_new(self):
self.assertTrue(self.hive is not None)
- def test_flush(self):
- self.hive.flush()
+ #def test_flush(self):
+ # self.hive.flush()
- def test_del_value(self):
- self.hive.del_value("FOO")
+ #def test_del_value(self):
+ # self.hive.del_value("FOO")
class RegistryTests(unittest.TestCase):
diff --git a/source4/lib/talloc/talloc.i b/source4/lib/talloc/talloc.i
index c852ae8f9f..a9afb97ed7 100644
--- a/source4/lib/talloc/talloc.i
+++ b/source4/lib/talloc/talloc.i
@@ -19,7 +19,7 @@
/* Don't expose talloc contexts in Python code. Python does reference
counting for us, so just create a new top-level talloc context.
*/
-%typemap(in, numinputs=0) TALLOC_CTX * {
+%typemap(in, numinputs=0, noblock=1) TALLOC_CTX * {
$1 = NULL;
}
diff --git a/source4/lib/tdb/tdb.i b/source4/lib/tdb/tdb.i
index 03b71fa586..5bb6506d93 100644
--- a/source4/lib/tdb/tdb.i
+++ b/source4/lib/tdb/tdb.i
@@ -49,7 +49,7 @@ typedef TDB_CONTEXT tdb;
%import exception.i
%import stdint.i
-%typemap(check) TDB_CONTEXT* {
+%typemap(check,noblock=1) TDB_CONTEXT* {
if ($1 == NULL)
SWIG_exception(SWIG_ValueError,
"tdb context must be non-NULL");
@@ -59,7 +59,7 @@ typedef TDB_CONTEXT tdb;
and from the Python string type which can contain arbitrary binary
data.. */
-%typemap(in) TDB_DATA {
+%typemap(in,noblock=1) TDB_DATA {
if (!PyString_Check($input)) {
PyErr_SetString(PyExc_TypeError, "string arg expected");
return NULL;
@@ -68,7 +68,7 @@ typedef TDB_CONTEXT tdb;
$1.dptr = (uint8_t *)PyString_AsString($input);
}
-%typemap(out) TDB_DATA {
+%typemap(out,noblock=1) TDB_DATA {
if ($1.dptr == NULL && $1.dsize == 0) {
$result = Py_None;
} else {
@@ -115,23 +115,23 @@ enum TDB_ERROR {
%rename(read_lock_all) tdb_context::lockall_read;
%rename(read_unlock_all) tdb_context::unlockall_read;
-%typemap(default) int tdb_flags {
+%typemap(default,noblock=1) int tdb_flags {
$1 = TDB_DEFAULT;
}
-%typemap(default) int open_flags {
+%typemap(default,noblock=1) int open_flags {
$1 = O_RDWR;
}
-%typemap(default) int hash_size {
+%typemap(default,noblock=1) int hash_size {
$1 = 0;
}
-%typemap(default) mode_t mode {
+%typemap(default,noblock=1) mode_t mode {
$1 = 0600;
}
-%typemap(default) int flag {
+%typemap(default,noblock=1) int flag {
$1 = TDB_REPLACE;
}
diff --git a/source4/lib/tdb/tdb_wrap.c b/source4/lib/tdb/tdb_wrap.c
index 841cd78399..1ba7481af0 100644
--- a/source4/lib/tdb/tdb_wrap.c
+++ b/source4/lib/tdb/tdb_wrap.c
@@ -2831,18 +2831,10 @@ SWIGINTERN PyObject *_wrap_new_Tdb(PyObject *SWIGUNUSEDPARM(self), PyObject *arg
(char *) "name",(char *) "hash_size",(char *) "tdb_flags",(char *) "open_flags",(char *) "mode", NULL
};
- {
- arg2 = 0;
- }
- {
- arg3 = TDB_DEFAULT;
- }
- {
- arg4 = O_RDWR;
- }
- {
- arg5 = 0600;
- }
+ arg2 = 0;
+ arg3 = TDB_DEFAULT;
+ arg4 = O_RDWR;
+ arg5 = 0600;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|OOOO:new_Tdb",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1);
if (!SWIG_IsOK(res1)) {
@@ -2977,22 +2969,18 @@ SWIGINTERN PyObject *_wrap_tdb_append(PyObject *SWIGUNUSEDPARM(self), PyObject *
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_append" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
- {
- if (!PyString_Check(obj1)) {
- PyErr_SetString(PyExc_TypeError, "string arg expected");
- return NULL;
- }
- (&arg2)->dsize = PyString_Size(obj1);
- (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
+ if (!PyString_Check(obj1)) {
+ PyErr_SetString(PyExc_TypeError, "string arg expected");
+ return NULL;
}
- {
- if (!PyString_Check(obj2)) {
- PyErr_SetString(PyExc_TypeError, "string arg expected");
- return NULL;
- }
- (&arg3)->dsize = PyString_Size(obj2);
- (&arg3)->dptr = (uint8_t *)PyString_AsString(obj2);
+ (&arg2)->dsize = PyString_Size(obj1);
+ (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
+ if (!PyString_Check(obj2)) {
+ PyErr_SetString(PyExc_TypeError, "string arg expected");
+ return NULL;
}
+ (&arg3)->dsize = PyString_Size(obj2);
+ (&arg3)->dptr = (uint8_t *)PyString_AsString(obj2);
result = (int)tdb_append(arg1,arg2,arg3);
resultobj = SWIG_From_int((int)(result));
return resultobj;
@@ -3043,22 +3031,18 @@ SWIGINTERN PyObject *_wrap_tdb_fetch(PyObject *SWIGUNUSEDPARM(self), PyObject *a
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_fetch" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
- {
- if (!PyString_Check(obj1)) {
- PyErr_SetString(PyExc_TypeError, "string arg expected");
- return NULL;
- }
- (&arg2)->dsize = PyString_Size(obj1);
- (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
+ if (!PyString_Check(obj1)) {
+ PyErr_SetString(PyExc_TypeError, "string arg expected");
+ return NULL;
}
+ (&arg2)->dsize = PyString_Size(obj1);
+ (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
result = tdb_fetch(arg1,arg2);
- {
- if ((&result)->dptr == NULL && (&result)->dsize == 0) {
- resultobj = Py_None;
- } else {
- resultobj = PyString_FromStringAndSize((const char *)(&result)->dptr, (&result)->dsize);
- free((&result)->dptr);
- }
+ if ((&result)->dptr == NULL && (&result)->dsize == 0) {
+ resultobj = Py_None;
+ } else {
+ resultobj = PyString_FromStringAndSize((const char *)(&result)->dptr, (&result)->dsize);
+ free((&result)->dptr);
}
return resultobj;
fail:
@@ -3085,14 +3069,12 @@ SWIGINTERN PyObject *_wrap_tdb_delete(PyObject *SWIGUNUSEDPARM(self), PyObject *
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_delete" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
- {
- if (!PyString_Check(obj1)) {
- PyErr_SetString(PyExc_TypeError, "string arg expected");
- return NULL;
- }
- (&arg2)->dsize = PyString_Size(obj1);
- (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
+ if (!PyString_Check(obj1)) {
+ PyErr_SetString(PyExc_TypeError, "string arg expected");
+ return NULL;
}
+ (&arg2)->dsize = PyString_Size(obj1);
+ (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
result = (int)tdb_delete(arg1,arg2);
resultobj = SWIG_From_int((int)(result));
return resultobj;
@@ -3120,31 +3102,25 @@ SWIGINTERN PyObject *_wrap_tdb_store(PyObject *SWIGUNUSEDPARM(self), PyObject *a
(char *) "self",(char *) "key",(char *) "dbuf",(char *) "flag", NULL
};
- {
- arg4 = TDB_REPLACE;
- }
+ arg4 = TDB_REPLACE;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|O:tdb_store",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_store" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
- {
- if (!PyString_Check(obj1)) {
- PyErr_SetString(PyExc_TypeError, "string arg expected");
- return NULL;
- }
- (&arg2)->dsize = PyString_Size(obj1);
- (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
+ if (!PyString_Check(obj1)) {
+ PyErr_SetString(PyExc_TypeError, "string arg expected");
+ return NULL;
}
- {
- if (!PyString_Check(obj2)) {
- PyErr_SetString(PyExc_TypeError, "string arg expected");
- return NULL;
- }
- (&arg3)->dsize = PyString_Size(obj2);
- (&arg3)->dptr = (uint8_t *)PyString_AsString(obj2);
+ (&arg2)->dsize = PyString_Size(obj1);
+ (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
+ if (!PyString_Check(obj2)) {
+ PyErr_SetString(PyExc_TypeError, "string arg expected");
+ return NULL;
}
+ (&arg3)->dsize = PyString_Size(obj2);
+ (&arg3)->dptr = (uint8_t *)PyString_AsString(obj2);
if (obj3) {
ecode4 = SWIG_AsVal_int(obj3, &val4);
if (!SWIG_IsOK(ecode4)) {
@@ -3179,14 +3155,12 @@ SWIGINTERN PyObject *_wrap_tdb_exists(PyObject *SWIGUNUSEDPARM(self), PyObject *
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_exists" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
- {
- if (!PyString_Check(obj1)) {
- PyErr_SetString(PyExc_TypeError, "string arg expected");
- return NULL;
- }
- (&arg2)->dsize = PyString_Size(obj1);
- (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
+ if (!PyString_Check(obj1)) {
+ PyErr_SetString(PyExc_TypeError, "string arg expected");
+ return NULL;
}
+ (&arg2)->dsize = PyString_Size(obj1);
+ (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
result = (int)tdb_exists(arg1,arg2);
resultobj = SWIG_From_int((int)(result));
return resultobj;
@@ -3211,13 +3185,11 @@ SWIGINTERN PyObject *_wrap_tdb_firstkey(PyObject *SWIGUNUSEDPARM(self), PyObject
}
arg1 = (tdb *)(argp1);
result = tdb_firstkey(arg1);
- {
- if ((&result)->dptr == NULL && (&result)->dsize == 0) {
- resultobj = Py_None;
- } else {
- resultobj = PyString_FromStringAndSize((const char *)(&result)->dptr, (&result)->dsize);
- free((&result)->dptr);
- }
+ if ((&result)->dptr == NULL && (&result)->dsize == 0) {
+ resultobj = Py_None;
+ } else {
+ resultobj = PyString_FromStringAndSize((const char *)(&result)->dptr, (&result)->dsize);
+ free((&result)->dptr);
}
return resultobj;
fail:
@@ -3244,22 +3216,18 @@ SWIGINTERN PyObject *_wrap_tdb_nextkey(PyObject *SWIGUNUSEDPARM(self), PyObject
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_nextkey" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
- {
- if (!PyString_Check(obj1)) {
- PyErr_SetString(PyExc_TypeError, "string arg expected");
- return NULL;
- }
- (&arg2)->dsize = PyString_Size(obj1);
- (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
+ if (!PyString_Check(obj1)) {
+ PyErr_SetString(PyExc_TypeError, "string arg expected");
+ return NULL;
}
+ (&arg2)->dsize = PyString_Size(obj1);
+ (&arg2)->dptr = (uint8_t *)PyString_AsString(obj1);
result = tdb_nextkey(arg1,arg2);
- {
- if ((&result)->dptr == NULL && (&result)->dsize == 0) {
- resultobj = Py_None;
- } else {
- resultobj = PyString_FromStringAndSize((const char *)(&result)->dptr, (&result)->dsize);
- free((&result)->dptr);
- }
+ if ((&result)->dptr == NULL && (&result)->dsize == 0) {
+ resultobj = Py_None;
+ } else {
+ resultobj = PyString_FromStringAndSize((const char *)(&result)->dptr, (&result)->dsize);
+ free((&result)->dptr);
}
return resultobj;
fail:
diff --git a/source4/libcli/security/security_wrap.c b/source4/libcli/security/security_wrap.c
index 9c572425eb..58bfd19bec 100644
--- a/source4/libcli/security/security_wrap.c
+++ b/source4/libcli/security/security_wrap.c
@@ -2802,9 +2802,7 @@ SWIGINTERN PyObject *_wrap_new_SecurityToken(PyObject *SWIGUNUSEDPARM(self), PyO
TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ;
security_token *result = 0 ;
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!SWIG_Python_UnpackTuple(args,"new_SecurityToken",0,0,0)) SWIG_fail;
result = (security_token *)new_security_token(arg1);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_security_token, SWIG_POINTER_NEW | 0 );
@@ -3080,9 +3078,7 @@ SWIGINTERN PyObject *_wrap_new_security_descriptor(PyObject *SWIGUNUSEDPARM(self
TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ;
security_descriptor *result = 0 ;
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!SWIG_Python_UnpackTuple(args,"new_security_descriptor",0,0,0)) SWIG_fail;
result = (security_descriptor *)new_security_descriptor(arg1);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_security_descriptor, SWIG_POINTER_NEW | 0 );
@@ -3119,13 +3115,12 @@ SWIGINTERN PyObject *_wrap_security_descriptor_sacl_add(PyObject *SWIGUNUSEDPARM
}
arg2 = (struct security_ace *)(argp2);
result = security_descriptor_sacl_add(arg1,(struct security_ace const *)arg2);
- {
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
+ if (NT_STATUS_IS_ERR(result)) {
+ PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, nt_errstr(result));
+ PyErr_SetObject(PyExc_RuntimeError, obj);
+ SWIG_fail;
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
}
return resultobj;
fail:
@@ -3160,13 +3155,12 @@ SWIGINTERN PyObject *_wrap_security_descriptor_dacl_add(PyObject *SWIGUNUSEDPARM
}
arg2 = (struct security_ace *)(argp2);
result = security_descriptor_dacl_add(arg1,(struct security_ace const *)arg2);
- {
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
+ if (NT_STATUS_IS_ERR(result)) {
+ PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, nt_errstr(result));
+ PyErr_SetObject(PyExc_RuntimeError, obj);
+ SWIG_fail;
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
}
return resultobj;
fail:
@@ -3201,13 +3195,12 @@ SWIGINTERN PyObject *_wrap_security_descriptor_dacl_del(PyObject *SWIGUNUSEDPARM
}
arg2 = (struct security_ace *)(argp2);
result = security_descriptor_dacl_del(arg1,(struct security_ace const *)arg2);
- {
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
+ if (NT_STATUS_IS_ERR(result)) {
+ PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, nt_errstr(result));
+ PyErr_SetObject(PyExc_RuntimeError, obj);
+ SWIG_fail;
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
}
return resultobj;
fail:
@@ -3242,13 +3235,12 @@ SWIGINTERN PyObject *_wrap_security_descriptor_sacl_del(PyObject *SWIGUNUSEDPARM
}
arg2 = (struct security_ace *)(argp2);
result = security_descriptor_sacl_del(arg1,(struct security_ace const *)arg2);
- {
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
+ if (NT_STATUS_IS_ERR(result)) {
+ PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, nt_errstr(result));
+ PyErr_SetObject(PyExc_RuntimeError, obj);
+ SWIG_fail;
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
}
return resultobj;
fail:
@@ -3337,9 +3329,7 @@ SWIGINTERN PyObject *_wrap_new_Sid(PyObject *SWIGUNUSEDPARM(self), PyObject *arg
(char *) "text", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:new_Sid",kwnames,&obj0)) SWIG_fail;
res2 = SWIG_AsCharPtrAndSize(obj0, &buf2, NULL, &alloc2);
if (!SWIG_IsOK(res2)) {
@@ -3365,9 +3355,7 @@ SWIGINTERN PyObject *_wrap_Sid___str__(PyObject *SWIGUNUSEDPARM(self), PyObject
int res1 = 0 ;
PyObject *swig_obj[1] ;
- {
- arg2 = NULL;
- }
+ arg2 = NULL;
if (!args) SWIG_fail;
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_dom_sid, 0 | 0 );
@@ -3456,9 +3444,7 @@ SWIGINTERN PyObject *_wrap_random_sid(PyObject *SWIGUNUSEDPARM(self), PyObject *
TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ;
struct dom_sid *result = 0 ;
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!SWIG_Python_UnpackTuple(args,"random_sid",0,0,0)) SWIG_fail;
result = (struct dom_sid *)random_sid(arg1);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_dom_sid, 0 | 0 );
diff --git a/source4/libcli/util/errors.i b/source4/libcli/util/errors.i
index 8d97daf537..3f6efda468 100644
--- a/source4/libcli/util/errors.i
+++ b/source4/libcli/util/errors.i
@@ -18,7 +18,7 @@
*/
#ifdef SWIGPYTHON
-%typemap(out) WERROR {
+%typemap(out,noblock=1) WERROR {
if (!W_ERROR_IS_OK($1)) {
PyObject *obj = Py_BuildValue("(i,s)", $1.v, win_errstr($1));
PyErr_SetObject(PyExc_RuntimeError, obj);
@@ -28,7 +28,7 @@
}
};
-%typemap(out) NTSTATUS {
+%typemap(out,noblock=1) NTSTATUS {
if (NT_STATUS_IS_ERR($1)) {
PyObject *obj = Py_BuildValue("(i,s)", $1.v, nt_errstr($1));
PyErr_SetObject(PyExc_RuntimeError, obj);
@@ -38,7 +38,7 @@
}
};
-%typemap(in) NTSTATUS {
+%typemap(in,noblock=1) NTSTATUS {
if (PyLong_Check($input))
$1 = NT_STATUS(PyLong_AsUnsignedLong($input));
else if (PyInt_Check($input))
diff --git a/source4/librpc/rpc/dcerpc.i b/source4/librpc/rpc/dcerpc.i
index 862ba7d1b2..3b860c4fa4 100644
--- a/source4/librpc/rpc/dcerpc.i
+++ b/source4/librpc/rpc/dcerpc.i
@@ -44,11 +44,11 @@
%include "../../lib/talloc/talloc.i"
%include "../../auth/credentials/credentials.i"
-%typemap(in, numinputs=0) struct dcerpc_pipe **OUT (struct dcerpc_pipe *temp_dcerpc_pipe) {
+%typemap(in,noblock=1, numinputs=0) struct dcerpc_pipe **OUT (struct dcerpc_pipe *temp_dcerpc_pipe) {
$1 = &temp_dcerpc_pipe;
}
-%typemap(argout) struct dcerpc_pipe ** {
+%typemap(argout,noblock=1) struct dcerpc_pipe ** {
/* Set REF_ALLOC flag so we don't have to do too much extra
mucking around with ref variables in ndr unmarshalling. */
@@ -71,7 +71,7 @@ NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx,
struct cli_credentials *credentials,
struct loadparm_context *lp_ctx);
-%typemap(in) DATA_BLOB * (DATA_BLOB temp_data_blob) {
+%typemap(in,noblock=1) DATA_BLOB * (DATA_BLOB temp_data_blob) {
temp_data_blob.data = PyString_AsString($input);
temp_data_blob.length = PyString_Size($input);
$1 = &temp_data_blob;
@@ -83,16 +83,16 @@ const char *dcerpc_server_name(struct dcerpc_pipe *p);
also be done using the uint32 carray functions, but it's a bit of a
hassle. TODO: Fix memory leak here. */
-%typemap(in) uint32_t *resume_handle {
+%typemap(in,noblock=1) uint32_t *resume_handle {
$1 = malloc(sizeof(*$1));
*$1 = PyLong_AsLong($input);
}
-%typemap(out) uint32_t *resume_handle {
+%typemap(out,noblock=1) uint32_t *resume_handle {
$result = PyLong_FromLong(*$1);
}
-%typemap(in) struct policy_handle * {
+%typemap(in,noblock=1) struct policy_handle * {
if ((SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor,
SWIG_POINTER_EXCEPTION)) == -1)
@@ -108,7 +108,7 @@ const char *dcerpc_server_name(struct dcerpc_pipe *p);
as the talloc context it is created under is destroyed after the
wrapper function returns. TODO: Fix memory leak created here. */
-%typemap(out) struct policy_handle * {
+%typemap(out,noblock=1) struct policy_handle * {
if ($1) {
struct policy_handle *temp = (struct policy_handle *)malloc(sizeof(struct policy_handle));
memcpy(temp, $1, sizeof(struct policy_handle));
diff --git a/source4/librpc/rpc/dcerpc.py b/source4/librpc/rpc/dcerpc.py
index da3664d80e..71661ef7fa 100644
--- a/source4/librpc/rpc/dcerpc.py
+++ b/source4/librpc/rpc/dcerpc.py
@@ -57,6 +57,7 @@ def _swig_setattr_nondynamic_method(set):
return set_attr
+import param
class Credentials(object):
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
diff --git a/source4/librpc/rpc/dcerpc_wrap.c b/source4/librpc/rpc/dcerpc_wrap.c
index c60fef9e9d..0d4e875975 100644
--- a/source4/librpc/rpc/dcerpc_wrap.c
+++ b/source4/librpc/rpc/dcerpc_wrap.c
@@ -2461,11 +2461,22 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags)
#define SWIGTYPE_p_char swig_types[2]
#define SWIGTYPE_p_cli_credentials swig_types[3]
#define SWIGTYPE_p_dcerpc_pipe swig_types[4]
-#define SWIGTYPE_p_loadparm_context swig_types[5]
-#define SWIGTYPE_p_p_dcerpc_pipe swig_types[6]
-#define SWIGTYPE_p_uint32_t swig_types[7]
-static swig_type_info *swig_types[9];
-static swig_module_info swig_module = {swig_types, 8, 0, 0, 0, 0};
+#define SWIGTYPE_p_int swig_types[5]
+#define SWIGTYPE_p_loadparm_context swig_types[6]
+#define SWIGTYPE_p_loadparm_service swig_types[7]
+#define SWIGTYPE_p_long_long swig_types[8]
+#define SWIGTYPE_p_p_dcerpc_pipe swig_types[9]
+#define SWIGTYPE_p_param_context swig_types[10]
+#define SWIGTYPE_p_param_opt swig_types[11]
+#define SWIGTYPE_p_param_section swig_types[12]
+#define SWIGTYPE_p_short swig_types[13]
+#define SWIGTYPE_p_signed_char swig_types[14]
+#define SWIGTYPE_p_unsigned_char swig_types[15]
+#define SWIGTYPE_p_unsigned_int swig_types[16]
+#define SWIGTYPE_p_unsigned_long_long swig_types[17]
+#define SWIGTYPE_p_unsigned_short swig_types[18]
+static swig_type_info *swig_types[20];
+static swig_module_info swig_module = {swig_types, 19, 0, 0, 0, 0};
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
@@ -2528,6 +2539,7 @@ static swig_module_info swig_module = {swig_types, 8, 0, 0, 0, 0};
#include "includes.h"
#include "auth/credentials/credentials.h"
+#include "param/param.h"
typedef struct cli_credentials cli_credentials;
@@ -2536,7 +2548,6 @@ typedef struct cli_credentials cli_credentials;
SWIGINTERN cli_credentials *new_cli_credentials(){
return cli_credentials_init(NULL);
}
-SWIGINTERN void delete_cli_credentials(cli_credentials *self){ talloc_free(self); }
SWIGINTERN swig_type_info*
SWIG_pchar_descriptor(void)
@@ -2781,6 +2792,67 @@ SWIGINTERNINLINE PyObject*
return PyBool_FromLong(value ? 1 : 0);
}
+SWIGINTERN void delete_cli_credentials(cli_credentials *self){ talloc_free(self); }
+
+SWIGINTERN int
+SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val)
+{
+ if (PyInt_Check(obj)) {
+ long v = PyInt_AsLong(obj);
+ if (v >= 0) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ return SWIG_OverflowError;
+ }
+ } else if (PyLong_Check(obj)) {
+ unsigned long v = PyLong_AsUnsignedLong(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ PyErr_Clear();
+ }
+ }
+#ifdef SWIG_PYTHON_CAST_MODE
+ {
+ int dispatch = 0;
+ unsigned long v = PyLong_AsUnsignedLong(obj);
+ if (!PyErr_Occurred()) {
+ if (val) *val = v;
+ return SWIG_AddCast(SWIG_OK);
+ } else {
+ PyErr_Clear();
+ }
+ if (!dispatch) {
+ double d;
+ int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
+ if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) {
+ if (val) *val = (unsigned long)(d);
+ return res;
+ }
+ }
+ }
+#endif
+ return SWIG_TypeError;
+}
+
+
+SWIGINTERN int
+SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val)
+{
+ unsigned long v;
+ int res = SWIG_AsVal_unsigned_SS_long (obj, &v);
+ if (SWIG_IsOK(res)) {
+ if ((v > UINT_MAX)) {
+ return SWIG_OverflowError;
+ } else {
+ if (val) *val = (unsigned int)(v);
+ }
+ }
+ return res;
+}
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -2797,36 +2869,6 @@ fail:
}
-SWIGINTERN PyObject *_wrap_delete_Credentials(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- cli_credentials *arg1 = (cli_credentials *) 0 ;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject * obj0 = 0 ;
- char * kwnames[] = {
- (char *) "self", NULL
- };
-
- {
- arg1 = NULL;
- }
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:delete_Credentials",kwnames,&obj0)) SWIG_fail;
- if (obj0) {
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, SWIG_POINTER_DISOWN | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Credentials" "', argument " "1"" of type '" "cli_credentials *""'");
- }
- arg1 = (cli_credentials *)(argp1);
- }
- delete_cli_credentials(arg1);
-
- resultobj = SWIG_Py_Void();
- return resultobj;
-fail:
- return NULL;
-}
-
-
SWIGINTERN PyObject *_wrap_Credentials_get_username(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
cli_credentials *arg1 = (cli_credentials *) 0 ;
@@ -2838,9 +2880,7 @@ SWIGINTERN PyObject *_wrap_Credentials_get_username(PyObject *SWIGUNUSEDPARM(sel
(char *) "self", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_get_username",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -2877,9 +2917,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_username(PyObject *SWIGUNUSEDPARM(sel
(char *) "self",(char *) "value",(char *)"arg3", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:Credentials_set_username",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -2923,9 +2961,7 @@ SWIGINTERN PyObject *_wrap_Credentials_get_password(PyObject *SWIGUNUSEDPARM(sel
(char *) "self", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_get_password",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -2962,9 +2998,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_password(PyObject *SWIGUNUSEDPARM(sel
(char *) "self",(char *) "val",(char *)"arg3", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:Credentials_set_password",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3008,9 +3042,7 @@ SWIGINTERN PyObject *_wrap_Credentials_get_domain(PyObject *SWIGUNUSEDPARM(self)
(char *) "self", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_get_domain",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3047,9 +3079,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_domain(PyObject *SWIGUNUSEDPARM(self)
(char *) "self",(char *) "val",(char *)"arg3", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:Credentials_set_domain",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3093,9 +3123,7 @@ SWIGINTERN PyObject *_wrap_Credentials_get_realm(PyObject *SWIGUNUSEDPARM(self),
(char *) "self", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_get_realm",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3132,9 +3160,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_realm(PyObject *SWIGUNUSEDPARM(self),
(char *) "self",(char *) "val",(char *)"arg3", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:Credentials_set_realm",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3186,9 +3212,7 @@ SWIGINTERN PyObject *_wrap_Credentials_parse_string(PyObject *SWIGUNUSEDPARM(sel
(char *) "self",(char *) "text",(char *)"arg3", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:Credentials_parse_string",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3232,9 +3256,7 @@ SWIGINTERN PyObject *_wrap_Credentials_get_bind_dn(PyObject *SWIGUNUSEDPARM(self
(char *) "self", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_get_bind_dn",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3267,9 +3289,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_bind_dn(PyObject *SWIGUNUSEDPARM(self
(char *) "self",(char *) "bind_dn", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:Credentials_set_bind_dn",kwnames,&obj0,&obj1)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3306,9 +3326,7 @@ SWIGINTERN PyObject *_wrap_Credentials_get_workstation(PyObject *SWIGUNUSEDPARM(
(char *) "self", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_get_workstation",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3345,9 +3363,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_workstation(PyObject *SWIGUNUSEDPARM(
(char *) "self",(char *) "workstation",(char *) "obtained", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:Credentials_set_workstation",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3383,7 +3399,7 @@ fail:
SWIGINTERN PyObject *_wrap_Credentials_guess(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
cli_credentials *arg1 = (cli_credentials *) 0 ;
- struct loadparm_context *arg2 = (struct loadparm_context *) NULL ;
+ struct loadparm_context *arg2 = (struct loadparm_context *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
void *argp2 = 0 ;
@@ -3394,9 +3410,8 @@ SWIGINTERN PyObject *_wrap_Credentials_guess(PyObject *SWIGUNUSEDPARM(self), PyO
(char *) "self",(char *) "lp_ctx", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
+ arg2 = loadparm_init(NULL);
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:Credentials_guess",kwnames,&obj0,&obj1)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3431,9 +3446,7 @@ SWIGINTERN PyObject *_wrap_Credentials_is_anonymous(PyObject *SWIGUNUSEDPARM(sel
(char *) "self", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_is_anonymous",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3462,12 +3475,8 @@ SWIGINTERN PyObject *_wrap_Credentials_get_nt_hash(PyObject *SWIGUNUSEDPARM(self
(char *) "self", NULL
};
- {
- arg1 = NULL;
- }
- {
- arg2 = NULL;
- }
+ arg1 = NULL;
+ arg2 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_get_nt_hash",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3477,9 +3486,7 @@ SWIGINTERN PyObject *_wrap_Credentials_get_nt_hash(PyObject *SWIGUNUSEDPARM(self
arg1 = (cli_credentials *)(argp1);
}
result = (struct samr_Password *)cli_credentials_get_nt_hash(arg1,arg2);
- {
- resultobj = PyString_FromStringAndSize(result->hash, 16);
- }
+ resultobj = PyString_FromStringAndSize(result->hash, 16);
return resultobj;
fail:
return NULL;
@@ -3497,9 +3504,7 @@ SWIGINTERN PyObject *_wrap_Credentials_authentication_requested(PyObject *SWIGUN
(char *) "self", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_authentication_requested",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3527,9 +3532,7 @@ SWIGINTERN PyObject *_wrap_Credentials_wrong_password(PyObject *SWIGUNUSEDPARM(s
(char *) "self", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:Credentials_wrong_password",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
@@ -3546,6 +3549,34 @@ fail:
}
+SWIGINTERN PyObject *_wrap_delete_Credentials(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ cli_credentials *arg1 = (cli_credentials *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+ char * kwnames[] = {
+ (char *) "self", NULL
+ };
+
+ arg1 = NULL;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:delete_Credentials",kwnames,&obj0)) SWIG_fail;
+ if (obj0) {
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, SWIG_POINTER_DISOWN | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Credentials" "', argument " "1"" of type '" "cli_credentials *""'");
+ }
+ arg1 = (cli_credentials *)(argp1);
+ }
+ delete_cli_credentials(arg1);
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
SWIGINTERN PyObject *Credentials_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
@@ -3574,8 +3605,8 @@ SWIGINTERN PyObject *_wrap_pipe_connect(PyObject *SWIGUNUSEDPARM(self), PyObject
int res4 ;
char *buf4 = 0 ;
int alloc4 = 0 ;
- void *argp5 ;
- int res5 = 0 ;
+ unsigned int val5 ;
+ int ecode5 = 0 ;
void *argp6 = 0 ;
int res6 = 0 ;
void *argp7 = 0 ;
@@ -3589,15 +3620,10 @@ SWIGINTERN PyObject *_wrap_pipe_connect(PyObject *SWIGUNUSEDPARM(self), PyObject
(char *) "binding",(char *) "pipe_uuid",(char *) "pipe_version",(char *) "credentials",(char *) "lp_ctx", NULL
};
- {
- arg6 = NULL;
- }
- {
- arg1 = NULL;
- }
- {
- arg2 = &temp_dcerpc_pipe2;
- }
+ arg6 = NULL;
+ arg7 = loadparm_init(NULL);
+ arg1 = NULL;
+ arg2 = &temp_dcerpc_pipe2;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|OO:pipe_connect",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
res3 = SWIG_AsCharPtrAndSize(obj0, &buf3, NULL, &alloc3);
if (!SWIG_IsOK(res3)) {
@@ -3609,17 +3635,11 @@ SWIGINTERN PyObject *_wrap_pipe_connect(PyObject *SWIGUNUSEDPARM(self), PyObject
SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "pipe_connect" "', argument " "4"" of type '" "char const *""'");
}
arg4 = (char *)(buf4);
- {
- res5 = SWIG_ConvertPtr(obj2, &argp5, SWIGTYPE_p_uint32_t, 0 );
- if (!SWIG_IsOK(res5)) {
- SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "pipe_connect" "', argument " "5"" of type '" "uint32_t""'");
- }
- if (!argp5) {
- SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "pipe_connect" "', argument " "5"" of type '" "uint32_t""'");
- } else {
- arg5 = *((uint32_t *)(argp5));
- }
- }
+ ecode5 = SWIG_AsVal_unsigned_SS_int(obj2, &val5);
+ if (!SWIG_IsOK(ecode5)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "pipe_connect" "', argument " "5"" of type '" "uint32_t""'");
+ }
+ arg5 = (uint32_t)(val5);
if (obj3) {
res6 = SWIG_ConvertPtr(obj3, &argp6,SWIGTYPE_p_cli_credentials, 0 | 0 );
if (!SWIG_IsOK(res6)) {
@@ -3636,16 +3656,14 @@ SWIGINTERN PyObject *_wrap_pipe_connect(PyObject *SWIGUNUSEDPARM(self), PyObject
}
result = dcerpc_pipe_connect(arg1,arg2,(char const *)arg3,(char const *)arg4,arg5,arg6,arg7);
resultobj = SWIG_NewPointerObj((NTSTATUS *)memcpy((NTSTATUS *)malloc(sizeof(NTSTATUS)),&result,sizeof(NTSTATUS)), SWIGTYPE_p_NTSTATUS, SWIG_POINTER_OWN | 0 );
- {
- /* Set REF_ALLOC flag so we don't have to do too much extra
- mucking around with ref variables in ndr unmarshalling. */
-
- (*arg2)->conn->flags |= DCERPC_NDR_REF_ALLOC;
-
- /* Return swig handle on dcerpc_pipe */
-
- resultobj = SWIG_NewPointerObj(*arg2, SWIGTYPE_p_dcerpc_pipe, 0);
- }
+ /* Set REF_ALLOC flag so we don't have to do too much extra
+ mucking around with ref variables in ndr unmarshalling. */
+
+ (*arg2)->conn->flags |= DCERPC_NDR_REF_ALLOC;
+
+ /* Return swig handle on dcerpc_pipe */
+
+ resultobj = SWIG_NewPointerObj(*arg2, SWIGTYPE_p_dcerpc_pipe, 0);
if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
if (alloc4 == SWIG_NEWOBJ) free((char*)buf4);
return resultobj;
@@ -3683,7 +3701,6 @@ fail:
static PyMethodDef SwigMethods[] = {
{ (char *)"new_Credentials", (PyCFunction)_wrap_new_Credentials, METH_NOARGS, NULL},
- { (char *)"delete_Credentials", (PyCFunction) _wrap_delete_Credentials, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Credentials_get_username", (PyCFunction) _wrap_Credentials_get_username, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Credentials_set_username", (PyCFunction) _wrap_Credentials_set_username, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Credentials_get_password", (PyCFunction) _wrap_Credentials_get_password, METH_VARARGS | METH_KEYWORDS, NULL},
@@ -3702,6 +3719,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"Credentials_get_nt_hash", (PyCFunction) _wrap_Credentials_get_nt_hash, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Credentials_authentication_requested", (PyCFunction) _wrap_Credentials_authentication_requested, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Credentials_wrong_password", (PyCFunction) _wrap_Credentials_wrong_password, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"delete_Credentials", (PyCFunction) _wrap_delete_Credentials, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Credentials_swigregister", Credentials_swigregister, METH_VARARGS, NULL},
{ (char *)"Credentials_swiginit", Credentials_swiginit, METH_VARARGS, NULL},
{ (char *)"pipe_connect", (PyCFunction) _wrap_pipe_connect, METH_VARARGS | METH_KEYWORDS, NULL},
@@ -3717,9 +3735,20 @@ static swig_type_info _swigt__p_TALLOC_CTX = {"_p_TALLOC_CTX", "TALLOC_CTX *", 0
static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_cli_credentials = {"_p_cli_credentials", "struct cli_credentials *|cli_credentials *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_dcerpc_pipe = {"_p_dcerpc_pipe", "struct dcerpc_pipe *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_loadparm_context = {"_p_loadparm_context", "struct loadparm_context *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_int = {"_p_int", "intptr_t *|int *|int_least32_t *|int_fast32_t *|int32_t *|int_fast16_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_loadparm_context = {"_p_loadparm_context", "struct loadparm_context *|loadparm_context *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_loadparm_service = {"_p_loadparm_service", "struct loadparm_service *|loadparm_service *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_long_long = {"_p_long_long", "int_least64_t *|int_fast64_t *|int64_t *|long long *|intmax_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_p_dcerpc_pipe = {"_p_p_dcerpc_pipe", "struct dcerpc_pipe **", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_uint32_t = {"_p_uint32_t", "uint32_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_param_context = {"_p_param_context", "struct param_context *|param *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_param_opt = {"_p_param_opt", "struct param_opt *|param_opt *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_param_section = {"_p_param_section", "struct param_section *|param_section *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_short = {"_p_short", "short *|int_least16_t *|int16_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_signed_char = {"_p_signed_char", "signed char *|int_least8_t *|int_fast8_t *|int8_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *|uint_least8_t *|uint_fast8_t *|uint8_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "uintptr_t *|uint_least32_t *|uint_fast32_t *|uint32_t *|unsigned int *|uint_fast16_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_unsigned_long_long = {"_p_unsigned_long_long", "uint_least64_t *|uint_fast64_t *|uint64_t *|unsigned long long *|uintmax_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_unsigned_short = {"_p_unsigned_short", "unsigned short *|uint_least16_t *|uint16_t *", 0, 0, (void*)0, 0};
static swig_type_info *swig_type_initial[] = {
&_swigt__p_NTSTATUS,
@@ -3727,9 +3756,20 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_char,
&_swigt__p_cli_credentials,
&_swigt__p_dcerpc_pipe,
+ &_swigt__p_int,
&_swigt__p_loadparm_context,
+ &_swigt__p_loadparm_service,
+ &_swigt__p_long_long,
&_swigt__p_p_dcerpc_pipe,
- &_swigt__p_uint32_t,
+ &_swigt__p_param_context,
+ &_swigt__p_param_opt,
+ &_swigt__p_param_section,
+ &_swigt__p_short,
+ &_swigt__p_signed_char,
+ &_swigt__p_unsigned_char,
+ &_swigt__p_unsigned_int,
+ &_swigt__p_unsigned_long_long,
+ &_swigt__p_unsigned_short,
};
static swig_cast_info _swigc__p_NTSTATUS[] = { {&_swigt__p_NTSTATUS, 0, 0, 0},{0, 0, 0, 0}};
@@ -3737,9 +3777,20 @@ static swig_cast_info _swigc__p_TALLOC_CTX[] = { {&_swigt__p_TALLOC_CTX, 0, 0,
static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_cli_credentials[] = { {&_swigt__p_cli_credentials, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_dcerpc_pipe[] = { {&_swigt__p_dcerpc_pipe, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_loadparm_context[] = { {&_swigt__p_loadparm_context, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_loadparm_service[] = { {&_swigt__p_loadparm_service, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_long_long[] = { {&_swigt__p_long_long, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_p_dcerpc_pipe[] = { {&_swigt__p_p_dcerpc_pipe, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_uint32_t[] = { {&_swigt__p_uint32_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_param_context[] = { {&_swigt__p_param_context, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_param_opt[] = { {&_swigt__p_param_opt, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_param_section[] = { {&_swigt__p_param_section, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_short[] = { {&_swigt__p_short, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_signed_char[] = { {&_swigt__p_signed_char, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_unsigned_int[] = { {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_unsigned_long_long[] = { {&_swigt__p_unsigned_long_long, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_unsigned_short[] = { {&_swigt__p_unsigned_short, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info *swig_cast_initial[] = {
_swigc__p_NTSTATUS,
@@ -3747,9 +3798,20 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_char,
_swigc__p_cli_credentials,
_swigc__p_dcerpc_pipe,
+ _swigc__p_int,
_swigc__p_loadparm_context,
+ _swigc__p_loadparm_service,
+ _swigc__p_long_long,
_swigc__p_p_dcerpc_pipe,
- _swigc__p_uint32_t,
+ _swigc__p_param_context,
+ _swigc__p_param_opt,
+ _swigc__p_param_section,
+ _swigc__p_short,
+ _swigc__p_signed_char,
+ _swigc__p_unsigned_char,
+ _swigc__p_unsigned_int,
+ _swigc__p_unsigned_long_long,
+ _swigc__p_unsigned_short,
};
diff --git a/source4/param/param.i b/source4/param/param.i
index dca2496f94..f5877a167a 100644
--- a/source4/param/param.i
+++ b/source4/param/param.i
@@ -38,7 +38,7 @@ typedef struct param_opt param_opt;
%import "typemaps.i"
%import "../lib/talloc/talloc.i"
-%typemap(default) struct loadparm_context * {
+%typemap(default,noblock=1) struct loadparm_context * {
$1 = loadparm_init(NULL);
}
diff --git a/source4/param/param_wrap.c b/source4/param/param_wrap.c
index e66d8a2043..c2df6bd1d0 100644
--- a/source4/param/param_wrap.c
+++ b/source4/param/param_wrap.c
@@ -2762,9 +2762,7 @@ SWIGINTERN PyObject *_wrap_new_LoadParm(PyObject *SWIGUNUSEDPARM(self), PyObject
TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ;
loadparm_context *result = 0 ;
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!SWIG_Python_UnpackTuple(args,"new_LoadParm",0,0,0)) SWIG_fail;
result = (loadparm_context *)new_loadparm_context(arg1);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_loadparm_context, SWIG_POINTER_NEW | 0 );
@@ -2790,9 +2788,7 @@ SWIGINTERN PyObject *_wrap_LoadParm_load(PyObject *SWIGUNUSEDPARM(self), PyObjec
(char *) "self",(char *) "filename", NULL
};
- {
- arg1 = loadparm_init(NULL);
- }
+ arg1 = loadparm_init(NULL);
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:LoadParm_load",kwnames,&obj0,&obj1)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, 0 | 0 );
@@ -2829,9 +2825,7 @@ SWIGINTERN PyObject *_wrap_LoadParm___len__(PyObject *SWIGUNUSEDPARM(self), PyOb
(char *) "self", NULL
};
- {
- arg1 = loadparm_init(NULL);
- }
+ arg1 = loadparm_init(NULL);
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:LoadParm___len__",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, 0 | 0 );
@@ -2864,9 +2858,7 @@ SWIGINTERN PyObject *_wrap_LoadParm___getitem__(PyObject *SWIGUNUSEDPARM(self),
(char *) "self",(char *) "name", NULL
};
- {
- arg1 = loadparm_init(NULL);
- }
+ arg1 = loadparm_init(NULL);
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:LoadParm___getitem__",kwnames,&obj0,&obj1)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, 0 | 0 );
@@ -2903,9 +2895,7 @@ SWIGINTERN PyObject *_wrap_LoadParm_configfile(PyObject *SWIGUNUSEDPARM(self), P
(char *) "self", NULL
};
- {
- arg1 = loadparm_init(NULL);
- }
+ arg1 = loadparm_init(NULL);
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:LoadParm_configfile",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, 0 | 0 );
@@ -2938,9 +2928,7 @@ SWIGINTERN PyObject *_wrap_LoadParm_is_mydomain(PyObject *SWIGUNUSEDPARM(self),
(char *) "self",(char *) "domain", NULL
};
- {
- arg1 = loadparm_init(NULL);
- }
+ arg1 = loadparm_init(NULL);
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:LoadParm_is_mydomain",kwnames,&obj0,&obj1)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, 0 | 0 );
@@ -2982,9 +2970,7 @@ SWIGINTERN PyObject *_wrap_LoadParm_is_myname(PyObject *SWIGUNUSEDPARM(self), Py
(char *) "self",(char *) "name", NULL
};
- {
- arg1 = loadparm_init(NULL);
- }
+ arg1 = loadparm_init(NULL);
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:LoadParm_is_myname",kwnames,&obj0,&obj1)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, 0 | 0 );
@@ -3025,9 +3011,7 @@ SWIGINTERN PyObject *_wrap_LoadParm_use(PyObject *SWIGUNUSEDPARM(self), PyObject
(char *) "self",(char *) "param", NULL
};
- {
- arg1 = loadparm_init(NULL);
- }
+ arg1 = loadparm_init(NULL);
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:LoadParm_use",kwnames,&obj0,&obj1)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, 0 | 0 );
@@ -3072,9 +3056,7 @@ SWIGINTERN PyObject *_wrap_LoadParm_set(PyObject *SWIGUNUSEDPARM(self), PyObject
(char *) "self",(char *) "parm_name",(char *) "parm_value", NULL
};
- {
- arg1 = loadparm_init(NULL);
- }
+ arg1 = loadparm_init(NULL);
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:LoadParm_set",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, 0 | 0 );
@@ -3130,9 +3112,7 @@ SWIGINTERN PyObject *_wrap_LoadParm_get(PyObject *SWIGUNUSEDPARM(self), PyObject
(char *) "self",(char *) "param_name",(char *) "service_name", NULL
};
- {
- arg1 = loadparm_init(NULL);
- }
+ arg1 = loadparm_init(NULL);
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:LoadParm_get",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, 0 | 0 );
@@ -3177,9 +3157,7 @@ SWIGINTERN PyObject *_wrap_delete_LoadParm(PyObject *SWIGUNUSEDPARM(self), PyObj
(char *) "self", NULL
};
- {
- arg1 = loadparm_init(NULL);
- }
+ arg1 = loadparm_init(NULL);
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:delete_LoadParm",kwnames,&obj0)) SWIG_fail;
if (obj0) {
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, SWIG_POINTER_DISOWN | 0 );
@@ -3289,9 +3267,7 @@ SWIGINTERN PyObject *_wrap_new_ParamFile(PyObject *SWIGUNUSEDPARM(self), PyObjec
TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ;
param *result = 0 ;
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!SWIG_Python_UnpackTuple(args,"new_ParamFile",0,0,0)) SWIG_fail;
result = (param *)new_param(arg1);
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_param_context, SWIG_POINTER_NEW | 0 );
diff --git a/source4/samba4-knownfail b/source4/samba4-knownfail
index 227dad323c..b582d44097 100644
--- a/source4/samba4-knownfail
+++ b/source4/samba4-knownfail
@@ -33,3 +33,4 @@ RPC-NETLOGON.*.GetPassword
RPC-NETLOGON.*.GetTrustPasswords
BASE-CHARSET.*.Testing partial surrogate
.*NET-API-DELSHARE.* # DelShare isn't implemented yet
+ldap.python # Conversion not finished yet
diff --git a/source4/scripting/bin/samba3dump b/source4/scripting/bin/samba3dump
index 6b3d999803..44ffc6a861 100755
--- a/source4/scripting/bin/samba3dump
+++ b/source4/scripting/bin/samba3dump
@@ -1,234 +1,157 @@
-#!/bin/sh
-exec smbscript "$0" ${1+"$@"}
-/*
- Dump Samba3 data
- Copyright Jelmer Vernooij 2005
- Released under the GNU GPL v2 or later
-*/
-
-options = GetOptions(ARGV,
- "POPT_AUTOHELP",
- "POPT_COMMON_SAMBA",
- "POPT_COMMON_VERSION",
- 'format=s',
- 'quiet', 'blank');
-
-if (options == undefined) {
- println("Failed to parse options");
- return -1;
-}
-
-if (options.format == undefined) {
- options.format = "summary";
-}
-
-if (options.format != "summary" && options.format != "full") {
- printf("Unknown format %s\n", options.format);
- return -1;
-}
-
-libinclude("base.js");
-
-if (options.ARGV.length != 2) {
- println("Usage: samba3dump <libdir> <smb.conf>");
- return -1;
-}
-
-function print_header(txt)
-{
- printf("\n%s\n", txt);
- println("==========================================");
-}
-
-function print_samba3_policy(pol)
-{
- print_header("Account Policies");
- printf("Min password length: %d\n", pol.min_password_length);
- printf("Password history length: %d\n", pol.password_history);
- printf("User must logon to change password: %d\n", pol.user_must_logon_to_change_password);
- printf("Maximum password age: %d\n", pol.maximum_password_age);
- printf("Minimum password age: %d\n", pol.minimum_password_age);
- printf("Lockout duration: %d\n", pol.lockout_duration);
- printf("Reset Count Minutes: %d\n", pol.reset_count_minutes);
- printf("Bad Lockout Minutes: %d\n", pol.bad_lockout_minutes);
- printf("Disconnect Time: %d\n", pol.disconnect_time);
- printf("Refuse Machine Password Change: %d\n", pol.refuse_machine_password_change);
-}
-
-function print_samba3_sam(samba3)
-{
- var i;
- print_header("SAM Database");
+#!/usr/bin/python
+#
+# Dump Samba3 data
+# Copyright Jelmer Vernooij 2005-2007
+# Released under the GNU GPL v3 or later
+#
+
+import optparse
+import os, sys
+sys.path.append(os.path.join(os.path.dirname(__file__), "../python"))
+import samba
+import samba.samba3
+
+parser = optparse.OptionParser("provision <libdir> <smb.conf>")
+parser.add_option("--format", type="choice", metavar="FORMAT",
+ choices=["full", "summary"])
+
+opts, args = parser.parse_args()
+
+if opts.format is None:
+ opts.format = "summary"
+
+def print_header(txt):
+ print "\n%s" % txt
+ print "=========================================="
+
+def print_samba3_policy(pol):
+ print_header("Account Policies")
+ print "Min password length: %d" % pol.min_password_length
+ print "Password history length: %d" % pol.password_history
+ print "User must logon to change password: %d" % pol.user_must_logon_to_change_password
+ print "Maximum password age: %d" % pol.maximum_password_age
+ print "Minimum password age: %d" % pol.minimum_password_age
+ print "Lockout duration: %d" % pol.lockout_duration
+ print "Reset Count Minutes: %d" % pol.reset_count_minutes
+ print "Bad Lockout Minutes: %d" % pol.bad_lockout_minutes
+ print "Disconnect Time: %d" % pol.disconnect_time
+ print "Refuse Machine Password Change: %d" % pol.refuse_machine_password_change
+
+def print_samba3_sam(samba3):
+ print_header("SAM Database")
- for (i in samba3.samaccounts) {
- var a = samba3.samaccounts[i];
- printf("%d: %s\n", a.user_rid, a.username);
- }
-}
-
-function print_samba3_shares(samba3)
-{
- var i, j;
- print_header("Configured shares");
- for (i in samba3.shares) {
- var s = samba3.shares[i];
- printf("--- %s ---\n", s.name);
-
- for (j in s.parameters) {
- var p = s.parameters[j];
- printf("\t%s = %s\n", p.name, p.value);
- }
-
- println("");
- }
-}
-
-function print_samba3_secrets(secrets)
-{
- var i;
- print_header("Secrets");
-
- println("IPC Credentials:");
- if (secrets.ipc_cred.username_obtained)
- printf(" User: %s\n", secrets.ipc_cred.get_username);
- if (secrets.ipc_cred.password_obtained)
- printf(" Password: %s\n", secrets.ipc_cred.get_password);
-
- if (secrets.ipc_cred.domain_obtained)
- printf(" Domain: %s\n\n", secrets.ipc_cred.get_domain);
-
- println("LDAP passwords:");
- for (i in secrets.ldappws) {
- var pw = secrets.ldappws[i];
- printf("\t%s -> %s\n", pw.dn, pw.password);
- }
- println("");
-
- println("Domains:");
- for (i in secrets.domains) {
- var d = secrets.domains[i];
- printf("\t--- %s ---\n", d.name);
- printf("\tSID: %s\n", d.sid);
- printf("\tGUID: %s\n", d.guid);
- printf("\tPlaintext pwd: %s\n", d.plaintext_pw);
- printf("\tLast Changed: %lu\n", d.last_change_time);
- printf("\tSecure Channel Type: %d\n\n", d.sec_channel_type);
- }
-
- println("Trusted domains:");
- for (i in secrets.trusted_domains) {
- var td = secrets.trusted_domains[i];
- for (j = 0; j < td.uni_name_len; j++) {
- printf("\t--- %s ---\n", td.uni_name[j]);
- }
- printf("\tPassword: %s\n", td.pass);
- printf("\tModified: %lu\n", td.mod_time);
- printf("\tSID: %s\n", td.domain_sid);
- }
-}
-
-function print_samba3_regdb(regdb)
-{
- var i, j;
- print_header("Registry");
-
- for (i in regdb.keys) {
- var k = regdb.keys[i];
- printf("%s\n", k.name);
- for (j in k.values) {
- var v = k.values[j];
- printf("\t%s: type %d, length %d\n", v.name, v.type, v.data.length);
- }
- }
-}
-
-function print_samba3_winsdb(samba3)
-{
- var i;
- print_header("WINS Database");
-
- for (i in samba3.winsentries) {
- var e = samba3.winsentries[i];
- printf("%s, nb_flags: %x, type: %d, ttl: %lu, %d ips, fst: %s\n", e.name, e.nb_flags, e.type, e.ttl, e.ips.length, e.ips[0]);
- }
-}
-
-function print_samba3_groupmappings(groupdb)
-{
- print_header("Group Mappings");
+ for a in samba3.samaccounts:
+ print "%d: %s" % a.user_rid, a.username
+
+def print_samba3_shares(samba3):
+ print_header("Configured shares")
+ for s in samba3.shares:
+ print "--- %s ---" % s.name
+
+ for p in s.parameters:
+ print "\t%s = %s" % (p.name, p.value)
+
+ print ""
+
+def print_samba3_secrets(secrets):
+ print_header("Secrets")
+
+ print "IPC Credentials:"
+ if secrets.ipc_cred.username_obtained:
+ print " User: %s\n" % secrets.ipc_cred.get_username
+ if secrets.ipc_cred.password_obtained:
+ print " Password: %s\n" % secrets.ipc_cred.get_password
+
+ if secrets.ipc_cred.domain_obtained:
+ print " Domain: %s\n" % secrets.ipc_cred.get_domain
+
+ print "LDAP passwords:"
+ for pw in secrets.ldappws:
+ print "\t%s -> %s" % (pw.dn, pw.password)
+ print ""
+
+ print "Domains:"
+ for d in secrets.domains:
+ print "\t--- %s ---" % d.name
+ print "\tSID: %s" % d.sid
+ print "\tGUID: %s" % d.guid
+ print "\tPlaintext pwd: %s" % d.plaintext_pw
+ print "\tLast Changed: %lu" % d.last_change_time
+ print "\tSecure Channel Type: %d\n" % d.sec_channel_type
+
+ print "Trusted domains:"
+ for td in secrets.trusted_domains:
+ for n in td.uni_name:
+ print "\t--- %s ---" % n
+ print "\tPassword: %s" % td.password
+ print "\tModified: %lu" % td.mod_time
+ print "\tSID: %s" % td.domain_sid
+
+def print_samba3_regdb(regdb):
+ print_header("Registry")
+
+ for k in regdb.keys:
+ print "%s\n" % k.name
+ for v in regdb.values(k):
+ print "\t%s: type %d, length %d" % (v.name, v.type, v.data.length)
+
+def print_samba3_winsdb(samba3):
+ print_header("WINS Database")
+
+ for e in samba3.winsentries:
+ print "%s, nb_flags: %x, type: %d, ttl: %lu, %d ips, fst: %s" % (e.name, e.nb_flags, e.type, e.ttl, e.ips.length, e.ips[0])
+
+def print_samba3_groupmappings(groupdb):
+ print_header("Group Mappings")
- for (var i in groupdb.groupmappings) {
- var g = groupdb.groupmappings[i];
- printf("\t--- Group: %s ---\n", g.nt_name);
- printf("\tComment: %s\n", g.comment);
- printf("\tGID: %d\n", g.gid);
- printf("\tSID Name Use: %d\n", g.sid_name_use);
- printf("\tSID: %s\n\n", g.sid);
- }
-}
-
-function print_samba3_aliases(groupdb)
-{
- var i, j;
- for (i in groupdb.aliases) {
- var a = groupdb.aliases[i];
- printf("\t--- Alias: %s ---\n", a.sid);
- for (j in a.members) {
- printf("\t%s\n", a.members[j]);
- }
- }
-}
-
-function print_samba3_idmapdb(idmapdb)
-{
- var i;
- print_header("Winbindd SID<->GID/UID mappings");
-
- printf("User High Water Mark: %d\n", idmapdb.user_hwm);
- printf("Group High Water Mark: %d\n\n", idmapdb.group_hwm);
-
- for (i in idmapdb.mappings) {
- var e = idmapdb.mappings[i];
- printf("%s -> ", e.sid);
-
- if (e.type == e.IDMAP_GROUP) {
- printf("GID %d\n", e.unix_id);
- } else {
- printf("UID %d\n", e.unix_id);
- }
- }
-}
-
-function print_samba3(samba3)
-{
- print_samba3_sam(samba3);
- print_samba3_policy(samba3.policy);
- print_samba3_shares(samba3);
- print_samba3_winsdb(samba3);
- print_samba3_regdb(samba3.registry);
- print_samba3_secrets(samba3.secrets);
- print_samba3_groupmappings(samba3);
- print_samba3_aliases(samba3);
- print_samba3_idmapdb(samba3.idmapdb);
-}
-
-function print_samba3_summary(samba3)
-{
- printf("WINS db entries: %d\n", samba3.winsentries.length);
- printf("SAM Accounts: %d\n", samba3.samaccounts.length);
- printf("Registry key count: %d\n", samba3.registry.keys.length);
- printf("Shares (including [global]): %d\n", samba3.shares.length);
- printf("Groupmap count: %d\n", samba3.groupmappings.length);
- printf("Alias count: %d\n", samba3.aliases.length);
- printf("Idmap count: %d\n", samba3.idmapdb.mappings.length);
-}
-
-samba3 = samba3_read(options.ARGV[0], options.ARGV[1]);
-
-if (options.format == "summary") {
- print_samba3_summary(samba3);
-} else if (options.format == "full") {
- print_samba3(samba3);
-}
-
-return 0;
+ for g in groupdb.groupmappings:
+ print "\t--- Group: %s ---" % g.nt_name
+ print "\tComment: %s" % g.comment
+ print "\tGID: %d" % g.gid
+ print "\tSID Name Use: %d" % g.sid_name_use
+ print "\tSID: %s\n" % g.sid
+
+def print_samba3_aliases(groupdb):
+ for a in groupdb.aliases:
+ print "\t--- Alias: %s ---" % a.sid
+ for m in a.members:
+ print "\t%s" % m
+
+def print_samba3_idmapdb(idmapdb):
+ print_header("Winbindd SID<->GID/UID mappings")
+
+ print "User High Water Mark: %d" % idmapdb.user_hwm
+ print "Group High Water Mark: %d\n" % idmapdb.group_hwm
+
+ for e in idmapdb.mappings:
+ if e.type == e.IDMAP_GROUP:
+ print "%s -> GID %d" % (e.sid, e.unix_id)
+ else:
+ print "%s -> UID %d" % (e.sid, e.unix_id)
+
+def print_samba3(samba3):
+ print_samba3_sam(samba3)
+ print_samba3_policy(samba3.get_policy_db())
+ print_samba3_shares(samba3)
+ print_samba3_winsdb(samba3.get_wins_db())
+ print_samba3_regdb(samba3.get_registry())
+ print_samba3_secrets(samba3.get_secrets_db())
+ print_samba3_groupmappings(samba3.get_groupmapping_db())
+ print_samba3_aliases(samba3)
+ print_samba3_idmapdb(samba3.get_idmap_db())
+
+def print_samba3_summary(samba3):
+ print "WINS db entries: %d" % len(samba3.winsentries)
+ print "SAM Accounts: %d" % len(samba3.samaccounts)
+ print "Registry key count: %d" % len(samba3.registry.keys)
+ print "Shares (including [global]): %d" % len(samba3.shares)
+ print "Groupmap count: %d" % len(samba3.groupmappings)
+ print "Alias count: %d" % len(samba3.aliases)
+ print "Idmap count: %d" % len(samba3.idmapdb.mappings)
+
+samba3 = samba.samba3.Samba3(args[0], args[1])
+
+if opts.format == "summary":
+ print_samba3_summary(samba3)
+elif opts.format == "full":
+ print_samba3(samba3)
diff --git a/source4/scripting/bin/winreg.py b/source4/scripting/bin/winreg.py
new file mode 100644
index 0000000000..6cdc3a5898
--- /dev/null
+++ b/source4/scripting/bin/winreg.py
@@ -0,0 +1,93 @@
+#!/usr/bin/python
+#
+# tool to manipulate a remote registry
+# Copyright Andrew Tridgell 2005
+# Copyright Jelmer Vernooij 2007
+# Released under the GNU GPL v3 or later
+#
+
+import sys
+
+options = GetOptions(ARGV,
+ "POPT_AUTOHELP",
+ "POPT_COMMON_SAMBA",
+ "POPT_COMMON_CREDENTIALS",
+ "createkey=s")
+if (options == undefined) {
+ print "Failed to parse options"
+ sys.exit(-1)
+
+if len(sys.argv < 2:
+ print "Usage: %s <BINDING> [path]" % sys.argv[0]
+ sys.exit(-1)
+
+binding = options.ARGV[0]
+reg = winregObj()
+
+print "Connecting to " + binding
+status = reg.connect(binding)
+if (status.is_ok != true) {
+ print("Failed to connect to " + binding + " - " + status.errstr + "\n")
+ return -1
+}
+
+def list_values(path):
+ list = reg.enum_values(path)
+ if (list == undefined) {
+ return
+ }
+ for (i=0;i<list.length;i++) {
+ v = list[i]
+ printf("\ttype=%-30s size=%4d '%s'\n", reg.typestring(v.type), v.size, v.name)
+ if (v.type == reg.REG_SZ || v.type == reg.REG_EXPAND_SZ) {
+ printf("\t\t'%s'\n", v.value)
+ }
+ if (v.type == reg.REG_MULTI_SZ) {
+ for (j in v.value) {
+ printf("\t\t'%s'\n", v.value[j])
+ }
+ }
+ if (v.type == reg.REG_DWORD || v.type == reg.REG_DWORD_BIG_ENDIAN) {
+ printf("\t\t0x%08x (%d)\n", v.value, v.value)
+ }
+ if (v.type == reg.REG_QWORD) {
+ printf("\t\t0x%llx (%lld)\n", v.value, v.value)
+ }
+ }
+
+def list_path(path):
+ count = 0
+ list = reg.enum_path(path)
+ if (list == undefined) {
+ println("Unable to list " + path)
+ return 0
+ }
+ list_values(path)
+ count = count + list.length
+ for (i=0;i<list.length;i++) {
+ if (path) {
+ npath = path + "\\" + list[i]
+ } else {
+ npath = list[i]
+ }
+ println(npath)
+ count = count + list_path(npath)
+ }
+ return count
+
+if len(sys.argv) > 2:
+ root = sys.argv[2]
+else:
+ root = ''
+
+if options.createkey:
+ try:
+ reg.create_key("HKLM\\SOFTWARE", options.createkey)
+ except:
+ print "Failed to create key"
+else:
+ printf("Listing registry tree '%s'\n", root)
+ count = list_path(root)
+ if count == 0:
+ println("No entries found")
+ sys.exit(1)
diff --git a/source4/scripting/ejs/smbcalls_reg.c b/source4/scripting/ejs/smbcalls_reg.c
index fee11b66d9..30e5357cfb 100644
--- a/source4/scripting/ejs/smbcalls_reg.c
+++ b/source4/scripting/ejs/smbcalls_reg.c
@@ -54,7 +54,7 @@ static int ejs_apply_patchfile(MprVarHandle eid, int argc, struct MprVar **argv)
return -1;
}
- error = reg_diff_apply(mprToString(argv[0]), rctx);
+ error = reg_diff_apply(rctx, mprToString(argv[0]));
mpr_Return(eid, mprWERROR(error));
diff --git a/source4/scripting/python/misc_wrap.c b/source4/scripting/python/misc_wrap.c
index dc1203e2f0..0f36647487 100644
--- a/source4/scripting/python/misc_wrap.c
+++ b/source4/scripting/python/misc_wrap.c
@@ -2808,9 +2808,7 @@ SWIGINTERN PyObject *_wrap_random_password(PyObject *SWIGUNUSEDPARM(self), PyObj
(char *) "len", NULL
};
- {
- arg1 = NULL;
- }
+ arg1 = NULL;
if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:random_password",kwnames,&obj0)) SWIG_fail;
ecode2 = SWIG_AsVal_size_t(obj0, &val2);
if (!SWIG_IsOK(ecode2)) {
@@ -2855,11 +2853,9 @@ SWIGINTERN PyObject *_wrap_ldb_set_credentials(PyObject *SWIGUNUSEDPARM(self), P
}
arg2 = (struct cli_credentials *)(argp2);
}
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
ldb_set_credentials(arg1,arg2);
resultobj = SWIG_Py_Void();
return resultobj;
@@ -2893,11 +2889,9 @@ SWIGINTERN PyObject *_wrap_ldb_set_session_info(PyObject *SWIGUNUSEDPARM(self),
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_set_session_info" "', argument " "2"" of type '" "struct auth_session_info *""'");
}
arg2 = (struct auth_session_info *)(argp2);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
ldb_set_session_info(arg1,arg2);
resultobj = SWIG_Py_Void();
return resultobj;
@@ -2936,11 +2930,9 @@ SWIGINTERN PyObject *_wrap_ldb_set_loadparm(PyObject *SWIGUNUSEDPARM(self), PyOb
}
arg2 = (struct loadparm_context *)(argp2);
}
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
ldb_set_loadparm(arg1,arg2);
resultobj = SWIG_Py_Void();
return resultobj;
@@ -2975,11 +2967,9 @@ SWIGINTERN PyObject *_wrap_samdb_set_domain_sid(PyObject *SWIGUNUSEDPARM(self),
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "samdb_set_domain_sid" "', argument " "2"" of type '" "struct dom_sid const *""'");
}
arg2 = (struct dom_sid *)(argp2);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
result = (bool)samdb_set_domain_sid(arg1,(struct dom_sid const *)arg2);
resultobj = SWIG_From_bool((bool)(result));
return resultobj;
@@ -3025,19 +3015,16 @@ SWIGINTERN PyObject *_wrap_dsdb_attach_schema_from_ldif_file(PyObject *SWIGUNUSE
SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "dsdb_attach_schema_from_ldif_file" "', argument " "3"" of type '" "char const *""'");
}
arg3 = (char *)(buf3);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
result = dsdb_attach_schema_from_ldif_file(arg1,(char const *)arg2,(char const *)arg3);
- {
- if (!W_ERROR_IS_OK(result)) {
- PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
+ if (!W_ERROR_IS_OK(result)) {
+ PyObject *obj = Py_BuildValue("(i,s)", (&result)->v, win_errstr(result));
+ PyErr_SetObject(PyExc_RuntimeError, obj);
+ SWIG_fail;
+ } else if (resultobj == NULL) {
+ resultobj = Py_None;
}
if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
@@ -3079,11 +3066,9 @@ SWIGINTERN PyObject *_wrap_dsdb_set_global_schema(PyObject *SWIGUNUSEDPARM(self)
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsdb_set_global_schema" "', argument " "1"" of type '" "struct ldb_context *""'");
}
arg1 = (struct ldb_context *)(argp1);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
result = (int)dsdb_set_global_schema(arg1);
resultobj = SWIG_From_int((int)(result));
return resultobj;
@@ -3109,11 +3094,9 @@ SWIGINTERN PyObject *_wrap_ldb_register_samba_handlers(PyObject *SWIGUNUSEDPARM(
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_register_samba_handlers" "', argument " "1"" of type '" "struct ldb_context *""'");
}
arg1 = (struct ldb_context *)(argp1);
- {
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- }
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
result = (int)ldb_register_samba_handlers(arg1);
resultobj = SWIG_From_int((int)(result));
return resultobj;
diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py
index c735361353..5b34534133 100644
--- a/source4/scripting/python/samba/__init__.py
+++ b/source4/scripting/python/samba/__init__.py
@@ -91,7 +91,14 @@ class Ldb(ldb.Ldb):
def searchone(self, basedn, attribute, expression=None,
scope=ldb.SCOPE_BASE):
- """Search for one attribute as a string."""
+ """Search for one attribute as a string.
+
+ :param basedn: BaseDN for the search.
+ :param attribute: Name of the attribute
+ :param expression: Optional search expression.
+ :param scope: Search scope (defaults to base).
+ :return: Value of attribute as a string or None if it wasn't found.
+ """
res = self.search(basedn, scope, expression, [attribute])
if len(res) != 1 or res[0][attribute] is None:
return None
@@ -100,7 +107,7 @@ class Ldb(ldb.Ldb):
return values.pop()
def erase(self):
- """Erase an ldb, removing all records."""
+ """Erase this ldb, removing all records."""
# delete the specials
for attr in ["@INDEXLIST", "@ATTRIBUTES", "@SUBCLASSES", "@MODULES",
"@OPTIONS", "@PARTITION", "@KLUDGEACL"]:
@@ -149,13 +156,18 @@ class Ldb(ldb.Ldb):
:param ldif_path: Path to LDIF file.
"""
- self.load_ldif_add(open(ldif_path, 'r').read())
+ self.add_ldif(open(ldif_path, 'r').read())
- def load_ldif_add(self, ldif):
+ def add_ldif(self, ldif):
for changetype, msg in self.parse_ldif(ldif):
assert changetype == ldb.CHANGETYPE_NONE
self.add(msg)
+ def modify_ldif(self, ldif):
+ for (changetype, msg) in ldb.parse_ldif(data):
+ assert changetype == CHANGETYPE_MODIFY
+ ldb.modify(msg)
+
def substitute_var(text, values):
"""substitute strings of the form ${NAME} in str, replacing
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index dcf567954a..a4e6c6a214 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -111,9 +111,7 @@ def setup_modify_ldif(ldb, ldif_path, substvars=None):
assert "${" not in data
- for (changetype, msg) in ldb.parse_ldif(data):
- assert changetype == CHANGETYPE_MODIFY
- ldb.modify(msg)
+ ldb.modify_ldif(data)
def setup_ldb(ldb, ldif_path, subst_vars):
diff --git a/source4/scripting/python/samba/samba3.py b/source4/scripting/python/samba/samba3.py
new file mode 100644
index 0000000000..d8289ae756
--- /dev/null
+++ b/source4/scripting/python/samba/samba3.py
@@ -0,0 +1,224 @@
+#!/usr/bin/python
+
+# Unix SMB/CIFS implementation.
+# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+"""Support for reading Samba 3 data files."""
+
+REGISTRY_VALUE_PREFIX = "SAMBA_REGVAL"
+REGISTRY_DB_VERSION = 1
+
+import tdb
+
+class Registry:
+ """Simple read-only support for reading the Samba3 registry."""
+ def __init__(self, file):
+ self.tdb = tdb.Tdb(file)
+
+ def __len__(self):
+ """Return the number of keys."""
+ return len(self.keys())
+
+ def keys(self):
+ """Return list with all the keys."""
+ return [k.rstrip("\x00") for k in self.tdb.keys() if not k.startswith(REGISTRY_VALUE_PREFIX)]
+
+ def subkeys(self, key):
+ data = self.tdb.get(key)
+ if data is None:
+ return []
+ # FIXME: Parse data
+ return []
+
+ def values(self, key):
+ """Return a dictionary with the values set for a specific key."""
+ data = self.tdb.get("%s/%s" % (REGISTRY_VALUE_PREFIX, key))
+ if data is None:
+ return {}
+ # FIXME: Parse data
+ return {}
+
+
+class PolicyDatabase:
+ def __init__(self, file):
+ self.tdb = tdb.Tdb(file)
+ self.min_password_length = tdb.fetch_uint32("min password length")
+ self.user_must_logon_to_change_password = tdb.fetch_uint32("password history")
+ self.user_must_logon_to_change_password = tdb.fetch_uint32("user must logon to change pasword")
+ self.maximum_password_age = tdb.fetch_uint32("maximum password age")
+ self.minimum_password_age = tdb.fetch_uint32("minimum password age")
+ self.lockout_duration = tdb.fetch_uint32("lockout duration")
+ self.reset_count_minutes = tdb.fetch_uint32("reset count minutes")
+ self.bad_lockout_minutes = tdb.fetch_uint32("bad lockout minutes")
+ self.disconnect_time = tdb.fetch_uint32("disconnect time")
+ self.refuse_machine_password_change = tdb.fetch_uint32("refuse machine password change")
+
+ # FIXME: Read privileges as well
+
+
+GROUPDB_DATABASE_VERSION_V1 = 1 # native byte format.
+GROUPDB_DATABASE_VERSION_V2 = 2 # le format.
+
+GROUP_PREFIX = "UNIXGROUP/"
+
+# Alias memberships are stored reverse, as memberships. The performance
+# critical operation is to determine the aliases a SID is member of, not
+# listing alias members. So we store a list of alias SIDs a SID is member of
+# hanging of the member as key.
+MEMBEROF_PREFIX = "MEMBEROF/"
+
+class GroupMappingDatabase:
+ def __init__(self, file):
+ self.tdb = tdb.Tdb(file)
+
+
+# High water mark keys
+HWM_GROUP = "GROUP HWM"
+HWM_USER = "USER HWM"
+
+# idmap version determines auto-conversion
+IDMAP_VERSION = 2
+
+class IdmapDatabase:
+ def __init__(self, file):
+ self.tdb = tdb.Tdb(file)
+ assert self.tdb.fetch_int32("IDMAP_VERSION") == IDMAP_VERSION
+
+
+class SecretsDatabase:
+ def __init__(self, file):
+ self.tdb = tdb.Tdb(file)
+ self.domains = {}
+ for k, v in self.tdb.items():
+ if k == "SECRETS/AUTH_PASSWORD":
+ self.auth_password = v
+ elif k == "SECRETS/AUTH_DOMAIN":
+ self.auth_domain = v
+ elif k == "SECRETS/AUTH_USER":
+ self.auth_user = v
+ elif k.startswith("SECRETS/SID/"):
+ pass # FIXME
+ elif k.startswith("SECRETS/DOMGUID/"):
+ pass # FIXME
+ elif k.startswith("SECRETS/LDAP_BIND_PW/"):
+ pass # FIXME
+ elif k.startswith("SECRETS/AFS_KEYFILE/"):
+ pass # FIXME
+ elif k.startswith("SECRETS/MACHINE_SEC_CHANNEL_TYPE/"):
+ pass # FIXME
+ elif k.startswith("SECRETS/MACHINE_LAST_CHANGE_TIME/"):
+ pass # FIXME
+ elif k.startswith("SECRETS/MACHINE_PASSWORD/"):
+ pass # FIXME
+ elif k.startswith("SECRETS/$MACHINE.ACC/"):
+ pass # FIXME
+ elif k.startswith("SECRETS/$DOMTRUST.ACC/"):
+ pass # FIXME
+ elif k == "INFO/random_seed":
+ self.random_seed = v
+ else:
+ raise "Unknown key %s in secrets database" % k
+
+SHARE_DATABASE_VERSION_V1 = 1
+SHARE_DATABASE_VERSION_V2 = 2
+
+class ShareInfoDatabase:
+ def __init__(self, file):
+ self.tdb = tdb.Tdb(file)
+ assert self.tdb.fetch_int32("INFO/version") in (SHARE_DATABASE_VERSION_V1, SHARE_DATABASE_VERSION_V2)
+
+ def get_secdesc(self, name):
+ secdesc = self.tdb.get("SECDESC/%s" % name)
+ # FIXME: Run ndr_pull_security_descriptor
+
+
+ACB_DISABLED = 0x00000001
+ACB_HOMDIRREQ = 0x00000002
+ACB_PWNOTREQ = 0x00000004
+ACB_TEMPDUP = 0x00000008
+ACB_NORMAL = 0x00000010
+ACB_MNS = 0x00000020
+ACB_DOMTRUST = 0x00000040
+ACB_WSTRUST = 0x00000080
+ACB_SVRTRUST = 0x00000100
+ACB_PWNOEXP = 0x00000200
+ACB_AUTOLOCK = 0x00000400
+ACB_ENC_TXT_PWD_ALLOWED = 0x00000800
+ACB_SMARTCARD_REQUIRED = 0x00001000
+ACB_TRUSTED_FOR_DELEGATION = 0x00002000
+ACB_NOT_DELEGATED = 0x00004000
+ACB_USE_DES_KEY_ONLY = 0x00008000
+ACB_DONT_REQUIRE_PREAUTH = 0x00010000
+ACB_PW_EXPIRED = 0x00020000
+ACB_NO_AUTH_DATA_REQD = 0x00080000
+
+acb_info_mapping = {
+ 'N': ACB_PWNOTREQ, # 'N'o password.
+ 'D': ACB_DISABLED, # 'D'isabled.
+ 'H': ACB_HOMDIRREQ, # 'H'omedir required.
+ 'T': ACB_TEMPDUP, # 'T'emp account.
+ 'U': ACB_NORMAL, # 'U'ser account (normal).
+ 'M': ACB_MNS, # 'M'NS logon user account. What is this ?
+ 'W': ACB_WSTRUST, # 'W'orkstation account.
+ 'S': ACB_SVRTRUST, # 'S'erver account.
+ 'L': ACB_AUTOLOCK, # 'L'ocked account.
+ 'X': ACB_PWNOEXP, # No 'X'piry on password
+ 'I': ACB_DOMTRUST, # 'I'nterdomain trust account.
+ ' ': 0
+ }
+
+
+class Smbpasswd:
+ def __init__(self, file):
+ pass
+
+
+class TdbSam:
+ def __init__(self, file):
+ self.tdb = tdb.Tdb(file)
+
+
+class WinsDatabase:
+ def __init__(self, file):
+ pass
+
+
+class Samba3:
+ def __init__(self, smbconfpath, libdir):
+ self.smbconfpath = smbconfpath
+ self.libdir = libdir
+
+ def get_policy_db(self):
+ return PolicyDatabase(os.path.join(libdir, "account_policy.tdb"))
+
+ def get_registry(self):
+ return Registry(os.path.join(libdir, "registry.tdb"))
+
+ def get_secrets_db(self):
+ return SecretsDatabase(os.path.join(libdir, "secrets.tdb"))
+
+ def get_shares_db(self):
+ return ShareInfoDatabase(os.path.join(libdir, "share_info.tdb"))
+
+ def get_idmap_db(self):
+ return IdmapDatabase(os.path.join(libdir, "winbindd_idmap.tdb"))
+
+ def get_wins_db(self):
+ return WinsDatabase(os.path.join(libdir, "wins.dat"))
+
+ def get_groupmapping_db(self):
+ return GroupMappingDatabase(os.path.join(libdir, "group_mapping.tdb"))
diff --git a/source4/scripting/python/samba/tests/__init__.py b/source4/scripting/python/samba/tests/__init__.py
index e213c1cc1f..b01807c02f 100644
--- a/source4/scripting/python/samba/tests/__init__.py
+++ b/source4/scripting/python/samba/tests/__init__.py
@@ -43,6 +43,7 @@ class TestCaseInTempDir(unittest.TestCase):
def tearDown(self):
super(TestCaseInTempDir, self).tearDown()
+ # FIXME: Remove all files in self.tempdir
class SubstituteVarTestCase(unittest.TestCase):
diff --git a/source4/scripting/python/samba/tests/samba3.py b/source4/scripting/python/samba/tests/samba3.py
new file mode 100644
index 0000000000..c6b6281c60
--- /dev/null
+++ b/source4/scripting/python/samba/tests/samba3.py
@@ -0,0 +1,57 @@
+#!/usr/bin/python
+
+# Unix SMB/CIFS implementation.
+# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+import unittest
+from samba.samba3 import GroupMappingDatabase, Registry, PolicyDatabase
+import os
+
+DATADIR=os.path.join(os.path.dirname(__file__), "../../../../../testdata/samba3")
+
+class RegistryTestCase(unittest.TestCase):
+ def setUp(self):
+ self.registry = Registry(os.path.join(DATADIR, "registry.tdb"))
+
+ def test_length(self):
+ self.assertEquals(28, len(self.registry))
+
+ def test_keys(self):
+ self.assertEquals([], self.registry.keys())
+
+
+class PolicyTestCase(unittest.TestCase):
+ def setUp(self):
+ self.policy = PolicyDatabase(os.path.join(DATADIR, "account_policy.tdb"))
+
+ def test_policy(self):
+ self.assertEquals(self.policy.min_password_length, 5)
+ self.assertEquals(self.policy.minimum_password_age, 0)
+ self.assertEquals(self.policy.maximum_password_age, 999999999)
+ self.assertEquals(self.policy.refuse_machine_password_change, 0)
+ self.assertEquals(self.policy.reset_count_minutes, 0)
+ self.assertEquals(self.policy.disconnect_time, -1)
+ self.assertEquals(self.policy.user_must_logon_to_change_password, 0)
+ self.assertEquals(self.policy.password_history, 0)
+ self.assertEquals(self.policy.lockout_duration, 0)
+ self.assertEquals(self.policy.bad_lockout_minutes, 0)
+
+
+class GroupsTestCase(unittest.TestCase):
+ def setUp(self):
+ self.groupdb = GroupMappingDatabase(os.path.join(DATADIR, "group_mapping.tdb"))
+
diff --git a/source4/scripting/python/samba/upgrade.py b/source4/scripting/python/samba/upgrade.py
index 1c27f8ec25..3168fedf2d 100644
--- a/source4/scripting/python/samba/upgrade.py
+++ b/source4/scripting/python/samba/upgrade.py
@@ -7,7 +7,7 @@
"""Support code for upgrading from Samba 3 to Samba 4."""
-from provision import findnss
+from provision import findnss, provision
import provision
import grp
import pwd
@@ -69,7 +69,7 @@ data:: %s""" % (keydn, rv.name, rv.name, rv.type, ldb.encode(rv.data))
return ldif
-def upgrade_sam_policy(samba3,dn):
+def upgrade_sam_policy(policy,dn):
ldif = """
dn: %s
changetype: modify
@@ -84,11 +84,11 @@ samba3UserMustLogonToChangePassword: %d
samba3BadLockoutMinutes: %d
samba3DisconnectTime: %d
-""" % (dn, samba3.policy.min_password_length,
- samba3.policy.password_history, samba3.policy.minimum_password_age,
- samba3.policy.maximum_password_age, samba3.policy.lockout_duration,
- samba3.policy.reset_count_minutes, samba3.policy.user_must_logon_to_change_password,
- samba3.policy.bad_lockout_minutes, samba3.policy.disconnect_time)
+""" % (dn, policy.min_password_length,
+ policy.password_history, policy.minimum_password_age,
+ policy.maximum_password_age, policy.lockout_duration,
+ policy.reset_count_minutes, policy.user_must_logon_to_change_password,
+ policy.bad_lockout_minutes, policy.disconnect_time)
return ldif
@@ -465,7 +465,7 @@ replace: type
type: 4
replace: data
data: %d
-""" % samba3.policy.refuse_machine_password_change)
+""" % policy.refuse_machine_password_change)
message("Importing users")
for account in samba3.samaccounts:
diff --git a/source4/selftest/samba4_tests.sh b/source4/selftest/samba4_tests.sh
index 95baff2be7..16dd38802a 100755
--- a/source4/selftest/samba4_tests.sh
+++ b/source4/selftest/samba4_tests.sh
@@ -287,6 +287,7 @@ fi
# if python is available, run the python tests:
if which python 2>/dev/null >/dev/null
then
+ PYTHON=python
plantest "ldb.python" none PYTHONPATH=bin/python:scripting/python:lib/ldb/tests/python/ scripting/bin/subunitrun api
plantest "credentials.python" none PYTHONPATH=bin/python:scripting/python:auth/credentials/tests scripting/bin/subunitrun bindings
plantest "registry.python" none PYTHONPATH=bin/python:scripting/python:lib/registry/tests/ scripting/bin/subunitrun bindings
@@ -297,4 +298,7 @@ then
plantest "upgrade.python" none PYTHONPATH=bin/python:scripting/python scripting/bin/subunitrun samba.tests.upgrade
plantest "samba.python" none PYTHONPATH=bin/python:scripting/python scripting/bin/subunitrun samba.tests
plantest "provision.python" none PYTHONPATH=bin/python:scripting/python scripting/bin/subunitrun samba.tests.provision
+ plantest "samba3.python" none PYTHONPATH=bin/python:scripting/python scripting/bin/subunitrun samba.tests.samba3
+ plantest "samba3sam.python" none PYTHONPATH=bin/python:scripting/python $PYTHON dsdb/samdb/ldb_modules/tests/samba3sam.py `pwd` $DATADIR/samba3/
+ plantest "ldap.python" dc $PYTHON $samba4srcdir/lib/ldb/tests/python/ldap.py \$SERVER -U\$USERNAME%\$PASSWORD
fi