delete_user()

Deletes a user from the database table benutzer. Group associations (bgrel), system roles (ossysroles), subscriptions (osabonnement) and personal settings (osconf) are removed alongside. Portfolios and mailbox content can optionally be forwarded to another user.

1. Signature

  • Sync

  • Async

ecm.security.delete_user(
    user_guid: str,
    *,
    target_user_guid: str | None = None,
    forward_portfolios: bool = False,
    forward_mails: bool = False,
) -> None
await ecm.security.delete_user(...) -> None

2. Parameters

Parameter Default Description

user_guid

GUID of the user to delete.

target_user_guid

None

GUID of the recipient who inherits portfolios / mails. Effectively required by the server even when nothing is forwarded — the empty string is rejected (error -1040906141). The value must point to a different, existing user (e.g. the connected admin account). Required client-side when forward_portfolios or forward_mails is set.

forward_portfolios

False

Forward the user’s portfolios instead of deleting them.

forward_mails

False

Forward the user’s mailbox instead of deleting it.

3. Return value

None.

4. Errors

  • ValueError — when forward_* is set without target_user_guid.

  • ECMException (or subclass) on server failures.

5. Examples

5.1. Fully delete an account

target_user_guid is required by the server on v12. Pragmatically, pass the connected admin user as target.
  • Sync

  • Async

admin = ecm.security.user("root")
ecm.security.delete_user(user.guid, target_user_guid=admin.guid)
admin = await ecm.security.user("root")
await ecm.security.delete_user(user.guid, target_user_guid=admin.guid)

5.2. Forward portfolios and mailbox to a successor

old = ecm.security.user("alice")
new = ecm.security.user("bob")
assert old and new

ecm.security.delete_user(
    old.guid,
    target_user_guid=new.guid,
    forward_portfolios=True,
    forward_mails=True,
)

6. See also