def rule(event):
    if all(
        [
            event.deep_get("EventID", default="") == 4661,
            event.deep_get("AccessMask", default="") == "0x2d",
            event.deep_get("ObjectType", default="") in ["SAM_USER", "SAM_GROUP"],
            event.deep_get("ObjectName", default="").startswith("S-1-5-21-"),
            any(
                [
                    event.deep_get("ObjectName", default="").endswith("-500"),
                    event.deep_get("ObjectName", default="").endswith("-512"),
                ]
            ),
        ]
    ):
        return True
    return False
