]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:pyrpc: add conn.auth_info()
authorStefan Metzmacher <metze@samba.org>
Mon, 11 Nov 2024 22:20:52 +0000 (23:20 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 5 Dec 2024 16:46:37 +0000 (16:46 +0000)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source4/librpc/rpc/pyrpc.c

index 5ea829b80fb14e0cafd38cf337b90a7ff1b0252a..c1e93154b565ef48586f4f064015a3d92b5346f5 100644 (file)
@@ -311,6 +311,27 @@ static PyObject *py_iface_transport_encrypted(PyObject *self)
        Py_RETURN_FALSE;
 }
 
+static PyObject *py_iface_auth_info(PyObject *self)
+{
+       dcerpc_InterfaceObject *iface = (dcerpc_InterfaceObject *)self;
+       enum dcerpc_AuthType auth_type = DCERPC_AUTH_TYPE_NONE;
+       enum dcerpc_AuthLevel auth_level = DCERPC_AUTH_LEVEL_NONE;
+       PyObject *result = Py_None;
+
+       dcerpc_binding_handle_auth_info(iface->binding_handle,
+                                       &auth_type,
+                                       &auth_level);
+
+       result = Py_BuildValue("(I,I)",
+                              (unsigned)auth_type,
+                              (unsigned)auth_level);
+       if (result == NULL) {
+               return NULL;
+       }
+
+       return result;
+}
+
 static PyMethodDef dcerpc_interface_methods[] = {
        { "request", PY_DISCARD_FUNC_SIG(PyCFunction, py_iface_request),
                METH_VARARGS|METH_KEYWORDS,
@@ -319,6 +340,9 @@ static PyMethodDef dcerpc_interface_methods[] = {
        { "transport_encrypted", PY_DISCARD_FUNC_SIG(PyCFunction, py_iface_transport_encrypted),
                METH_NOARGS,
                "Check if the DCE transport is encrypted" },
+       { "auth_info", PY_DISCARD_FUNC_SIG(PyCFunction, py_iface_auth_info),
+               METH_NOARGS,
+               "Returns tuple of DCERPC auth type and auth level" },
        { NULL, NULL, 0, NULL },
 };