LDAP with AD remove users with empty mail

LDAP with AD remove users with empty mail

by Hubert Nagorny -
Number of replies: 1

Hello !
I have trouble with users from AD. I have ~860 users in AD, but some of them are names Department, fake users etc. I want add to moodle only users who have Name,Surname and Email. Rest of users i want remove. 
Please, help me

Average of ratings: -
In reply to Hubert Nagorny

Re: LDAP with AD remove users with empty mail

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

This sounds like a job for LDAP filters which are optionally specified in the Object class field on the LDAP Server configuration page in Moodle. If you put something like (&(objectClass=user)(sn=*)(mail=*)) only users with a surname and email address should be returned.

If you're using the scheduled task (LDAP users sync job) you can then remove the unwanted Moodle users by setting Removed ext user to "Full delete internal". Be careful, if there's a problem with the filter this could delete all the LDAP users in Moodle. Try setting this to "Suspend internal" initially, this will keep the users you don't want in Moodle but they'll be suspended.

Average of ratings: Useful (1)