Plugin to sync LDAP distribution lists with Discourse groups


I want to develop a plugin to sync LDAP Distribution lists with Discourse groups, but I am not sure how to go about writing the discourse side script for it. I’m wondering if it’s possible to directly use the GroupController and UserController classes or maybe if it’s a better idea to use the Ruby API instead. Or maybe there is another better way for this?