|| strequal(p->nc.dn, nc_dn_str)
|| (valid_sid && dom_sid_equal(&p->nc.sid, nc_sid)))
{
- /* fill in he right guid and sid if possible */
+ /*
+ * fill in he right guid and sid if possible also validate
+ * that guid match the guid of the partition and the
+ * sid also
+ */
if (nc_guid && !valid_guid) {
dsdb_get_extended_dn_guid(p->dn, nc_guid, "GUID");
+ } else if (nc_guid && valid_guid &&
+ !GUID_equal (&p->nc.guid, nc_guid))
+ {
+ /*
+ * NC was matching the DN or the SID but not
+ * the non null specified GUID -> BADNC
+ */
+ return WERR_DS_DRA_BAD_NC;
}
+
if (nc_sid && !valid_sid) {
dsdb_get_extended_dn_sid(p->dn, nc_sid, "SID");
+ } else if (nc_sid && valid_sid &&
+ !dom_sid_equal(&p->nc.sid, nc_sid))
+ {
+ /*
+ * NC was matching the DN or the GUID but not
+ * the non null specified SID -> BADNC
+ */
+ return WERR_DS_DRA_BAD_NC;
+ }
+
+ if (nc_dn_str && strequal(p->nc.dn, nc_dn_str) != 0) {
+ /*
+ * NC was matching the GUID or the SID but
+ * the DN itself didn't match -> BADNC
+ */
+ return WERR_DS_DRA_BAD_NC;
}
*_p = p;
return WERR_OK;