<commit_before><commit_msg>[ADD] Add script to remove all local identities<commit_after>import sys
from MaKaC.common.db import DBMgr
from MaKaC.user import AvatarHolder
from MaKaC.authentication import AuthenticatorMgr
from MaKaC.authentication.LocalAuthentication import LocalIdentity

print('This script will remove all local identities from users.')
print('This will remove passwords from the database and prevent them from')
print('logging in locally (so you need e.g. NICE or LDAP authentication)')
print
if raw_input('Do you want to continue? [yes|NO]: ').lower() != 'yes':
    print 'Cancelled.'
    sys.exit(0)

DBMgr.getInstance().startRequest()

ah = AvatarHolder()
am = AuthenticatorMgr()
for avatar in ah.getValuesToList():
    for identity in avatar.getIdentityList():
        if isinstance(identity, LocalIdentity):
            print('Removing LocalIdentity(%s, %s) from %s' %
                (identity.getLogin(), len(identity.password) * '*',
                    avatar.getFullName()))
            am.removeIdentity(identity)
            avatar.removeIdentity(identity)

DBMgr.getInstance().endRequest()
{'fraction_non_alphanumeric': 0.10545129579982127, 'fraction_numerical': 0.0008936550491510277, 'mean_word_length': 4.067873303167421, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2857114', 'n_tokens_mistral': 316, 'n_tokens_neox': 307, 'n_words': 96}