Programmer error! Bad Admin server handle
Torsten Kurbad
torsten at tk-webart.de
Fri Feb 15 03:53:45 EST 2008
Hi folks,
thanks for all the help!
My new snippet:
--- snip ---
static PyObject *getPrincipals(PyObject *self, PyObject *args)
{
char *client;
char *pass;
char *realm;
void *handle;
char **princs;
PyObject *pyprincs;
int count, i;
char *format_string = "";
krb5_context ctx;
krb5_error_code code = 0;
code = krb5_init_context(&ctx);
RETURN_ON_ERROR("krb5_init_context()", code);
if (!PyArg_ParseTuple(args, "sss", &client, &pass, &realm))
return NULL;
code = kadm5_init_with_password(client, pass, KADM5_ADMIN_SERVICE,
realm, KADM5_STRUCT_VERSION_1, KADM5_API_VERSION_1, NULL, &handle);
RETURN_ON_ERROR("kadm5_init_with_password()", code);
if (handle == NULL)
return Py_BuildValue("");
code = kadm5_get_principals(handle, "*", &princs, &count);
RETURN_ON_ERROR("kadm5_get_principals()", code);
if (princs == NULL)
return Py_BuildValue("");
pyprincs = PyList_New(count);
i = 0;
while (i < count)
{
code = PyList_SetItem(pyprincs, i,
PyString_FromString(princs[i])); if (code != 0)
{
return NULL;
}
i++;
}
return Py_BuildValue("O", pyprincs);
}
--- snap ---
Finally does what it should!
--
By working faithfully eight hours a day, you may eventually get to be
boss and work twelve.
-- Robert Frost
More information about the krbdev
mailing list