self.assertEquals(desc.sacl, None)
self.assertEquals(desc.type, 0x8004)
+ def test_as_sddl(self):
+ text = "O:AOG:DAD:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)"
+ dom = security.dom_sid("S-2-0-0")
+ desc1 = security.descriptor.from_sddl(text, dom)
+ desc2 = security.descriptor.from_sddl(desc1.as_sddl(dom), dom)
+ self.assertEquals(desc1.group_sid, desc2.group_sid)
+ self.assertEquals(desc1.owner_sid, desc2.owner_sid)
+ self.assertEquals(desc1.sacl, desc2.sacl)
+ self.assertEquals(desc1.type, desc2.type)
+
class DomSidTests(unittest.TestCase):
def test_parse_sid(self):
for (i = 0; methods[i].ml_name; i++) {
PyObject *descr;
if (methods[i].ml_flags & METH_CLASS)
- descr = PyCFunction_New(&methods[i], type);
+ descr = PyCFunction_New(&methods[i], (PyObject *)type);
else
descr = PyDescr_NewMethod(type, &methods[i]);
PyDict_SetItemString(dict, methods[i].ml_name,
return py_talloc_import((PyTypeObject *)self, secdesc);
}
+static PyObject *py_descriptor_as_sddl(PyObject *self, PyObject *py_sid)
+{
+ struct dom_sid *sid = py_talloc_get_ptr(py_sid);
+ struct security_descriptor *desc = py_talloc_get_ptr(self);
+ char *text;
+ PyObject *ret;
+
+ text = sddl_encode(NULL, desc, sid);
+
+ ret = PyString_FromString(text);
+
+ talloc_free(text);
+
+ return ret;
+}
+
static PyMethodDef py_descriptor_extra_methods[] = {
{ "sacl_add", (PyCFunction)py_descriptor_sacl_add, METH_VARARGS,
"S.sacl_add(ace) -> None\n"
NULL },
{ "from_sddl", (PyCFunction)py_descriptor_from_sddl, METH_VARARGS|METH_CLASS,
NULL },
+ { "as_sddl", (PyCFunction)py_descriptor_as_sddl, METH_O,
+ NULL },
{ NULL }
};