Example #1
0
    def get_directorship_heads(self, val):
        """Get the head of a directorship

        Arguments:
        val -- the cn of the directorship
        """

        __ldap_group_ou__ = "cn=groups,cn=accounts,dc=csh,dc=rit,dc=edu"

        res = self.__con__.search_s(
                __ldap_group_ou__,
                ldap.SCOPE_SUBTREE,
                "(cn=eboard-%s)" % val,
                ['member'])

        ret = []
        for member in res[0][1]['member']:
            try:
                ret.append(member.decode('utf-8'))
            except UnicodeDecodeError:
                ret.append(member)
            except KeyError:
                continue

        return [CSHMember(self,
                dn.split('=')[1].split(',')[0],
                True)
                for dn in ret]
Example #2
0
    def get_member(self, val, uid=False):
        """Get a CSHMember object.

        Arguments:
        val -- the uuid (or uid) of the member

        Keyword arguments:
        uid -- whether or not val is a uid (default False)
        """
        return CSHMember(self, val, uid)
Example #3
0
    def get_members(self):
        """Return all members in the group as CSHMember objects"""
        res = self.__con__.search_s(
                self.__ldap_base_dn__,
                ldap.SCOPE_SUBTREE,
                "(memberof=%s)" % self.__dn__,
                ['uid'])

        return [CSHMember(self.__lib__,
                result[1]['uid'][0],
                uid=True)
                for result in res]
Example #4
0
    def get_members(self):
        """Return all members in the group as CSHMember objects"""
        res = self.__con__.search_s(self.__ldap_base_dn__, ldap.SCOPE_SUBTREE,
                                    "(memberof=%s)" % self.__dn__, ['uid'])

        ret = []
        for val in res:
            val = val[1]['uid'][0]
            try:
                ret.append(val.decode('utf-8'))
            except UnicodeDecodeError:
                ret.append(val)
            except KeyError:
                continue

        return [CSHMember(self.__lib__, result, uid=True) for result in ret]
Example #5
0
    def get_member_ibutton(self, val):
        """Get a CSHMember object.

        Arguments:
        val -- the iButton ID of the member

        Returns:
        None if the iButton supplied does not correspond to a CSH Member
        """
        members = self.__con__.search_s(CSHMember.__ldap_user_ou__,
                                        ldap.SCOPE_SUBTREE,
                                        "(ibutton=%s)" % val, ['ipaUniqueID'])
        if members:
            return CSHMember(self,
                             members[0][1]['ipaUniqueID'][0].decode('utf-8'),
                             False)
        return None
Example #6
0
    def get_member_slackuid(self, slack):
        """Get a CSHMember object.

        Arguments:
        slack -- the Slack UID of the member

        Returns:
        None if the Slack UID provided does not correspond to a CSH Member
        """
        members = self.__con__.search_s(
            CSHMember.__ldap_user_ou__,
            ldap.SCOPE_SUBTREE,
            "(slackuid=%s)" % slack,
            ['ipaUniqueID'])
        if members:
            return CSHMember(
                    self,
                    members[0][1]['ipaUniqueID'][0].decode('utf-8'),
                    False)
        return None