40 lines
1.0 KiB
Python
40 lines
1.0 KiB
Python
from typing import Dict, List
|
|
|
|
from zope.interface import Interface, Attribute
|
|
|
|
from .IUser import IUser
|
|
|
|
|
|
class IGroup(Interface):
|
|
"""Represents a Unix group."""
|
|
|
|
cn = Attribute('common name')
|
|
gid_number = Attribute('gid number')
|
|
unique_members = Attribute('DNs of group members')
|
|
dn = Attribute('distinguished name')
|
|
|
|
def add_to_ldap():
|
|
"""Add a new record to LDAP for this group."""
|
|
|
|
def add_member(username: str):
|
|
"""Add the member to this group in LDAP."""
|
|
|
|
def remove_member(username: str):
|
|
"""Remove the member from this group in LDAP."""
|
|
|
|
def get_members() -> List[IUser]:
|
|
"""Get a list of the members in this group."""
|
|
|
|
def serialize_for_modlist() -> Dict[str, List[bytes]]:
|
|
"""
|
|
Serialize this group into a dict to be passed to
|
|
ldap.modlist.addModlist().
|
|
"""
|
|
|
|
# static method
|
|
def deserialize_from_dict(data: Dict[str, List[bytes]]):
|
|
"""Deserialize this group from a dict returned by ldap.search_s().
|
|
|
|
:returns: IGroup
|
|
"""
|