def find_group()

in ad-joining/register-computer/ad/domain.py [0:0]


    def find_group(self, search_base_dn):
        # Search either for the specific group or in the base DN (but not its descendants)
        if search_base_dn.startswith("CN="):
            search_scope = ldap3.BASE
        else:
            search_scope = ldap3.LEVEL

        try:
            return self.__find( 
                converter=self.__to_group,
                search_filter="(&(objectClass=group))",
                search_base_dn=search_base_dn,
                search_scope=search_scope,
                attributes=[
                    "distinguishedName",
                    "name",
                    ActiveDirectoryConnection.LDAP_ATTRIBUTE_GROUP_DATA
                ]
            )
        except ldap3.core.exceptions.LDAPNoSuchObjectResult as e:
            raise NoSuchObjectException(e)