Exemplo n.º 1
0
    def create_group(self,
                     name,
                     fullname='',
                     email='',
                     hidden=False,
                     groupid=None):
        """Create a new :class:`group <Group>` on the server.

        :param name: the name of the group
        :param fullname: the full name of the group (optional)
        :param email: the email address of the group (optional)
        :param hidden: hide the group (optional)
        :param groupid: the id of the group (optional)
        :return: :class:`group <Group>` the created group
        """
        name = _unicode(name)  # XXX: fullname/email unicode?
        email = _unicode(email)
        fullname = _unicode(fullname)
        try:
            self.sa.CreateGroup(
                ECGROUP(name, fullname, email, int(hidden), groupid),
                MAPI_UNICODE)
        except MAPIErrorNoSupport:
            raise NotSupportedError(
                "cannot create groups with configured user plugin")
        except MAPIErrorCollision:
            raise DuplicateError("group '%s' already exists" % name)

        return self.group(name)
Exemplo n.º 2
0
 def _update(self, **kwargs):
     # XXX: crashes server on certain characters...
     self._name = kwargs.get('name', self.name)
     fullname = kwargs.get('fullname', self.fullname)
     email = kwargs.get('email', self.email)
     hidden = kwargs.get('hidden', self.hidden)
     group = ECGROUP(self._name, fullname, email, int(hidden), self._ecgroup.GroupID)
     self.server.sa.SetGroup(group, MAPI_UNICODE)
     self._ecgroup = self.server.sa.GetGroup(self.server.sa.ResolveGroupName(self._name, MAPI_UNICODE), MAPI_UNICODE)