Merge the rest of security.i into samba.dcerpc.security.
[tprouty/samba.git] / source4 / librpc / ndr / py_security.c
index 11ad6ed2c45cb225c2700adcb2b7adbfcd266179..a7cb0515cf9bc0cd307f75b85c1601a58e5653b9 100644 (file)
@@ -270,3 +270,38 @@ static PyObject *py_token_new(PyTypeObject *self, PyObject *args, PyObject *kwar
                NULL }, \
        { "set_privilege", (PyCFunction)py_token_set_privilege, METH_VARARGS, \
                NULL },
+
+static PyObject *py_privilege_name(PyObject *self, PyObject *args)
+{
+       int priv;
+       if (!PyArg_ParseTuple(args, "i", &priv))
+               return NULL;
+
+       return PyString_FromString(sec_privilege_name(priv));
+}
+
+static PyObject *py_privilege_id(PyObject *self, PyObject *args)
+{
+       char *name;
+
+       if (!PyArg_ParseTuple(args, "s", &name))
+               return NULL;
+
+       return PyInt_FromLong(sec_privilege_id(name));
+}
+
+static PyObject *py_random_sid(PyObject *self)
+{
+       struct dom_sid *sid;
+       PyObject *ret;
+       char *str = talloc_asprintf(NULL, "S-1-5-21-%u-%u-%u", 
+                       (unsigned)generate_random(), 
+                       (unsigned)generate_random(), 
+                       (unsigned)generate_random());
+
+        sid = dom_sid_parse_talloc(NULL, str);
+       talloc_free(str);
+       ret = py_talloc_import(&PyDomSidType, sid);
+       talloc_free(sid);
+       return ret;
+}