How to Create a Script to "Bulk Remove" from a Group?

Continuing the discussion from Bulk add to Group:

@Falco and all, this is something that I would like to be able to do on the forum that I help run.

We have one category for “Members Only” - that is restricted to only our paid/active members - that I am able to import a list of users who currently have active accounts in our Active Directory through the Web Interface; however, there is no easy way to do a bulk remove of members who are no longer active from the group using the Web Interface.

I do have access to the server side and one of our admins already has a script to export the active accounts to a CSV file that includes the e-mail addresses of all currently active members; however, I do not know how to create a script that would remove all members from the restricted group on our forum, then add only the currently active members back to it (which sounds like basically what you are doing…). This is something that I would like to have done daily, as mentioned in the post quoted above.

Can you give me any pointers, please?

I think that what you want to do is have your developer use API calls to update Discourse when changes are made to the accounts rather than export a CSV daily. I’ve written one for the Wordpress MemberMouse plugin (I think that’s what it was).

Failing that, you might want a list of users to delete and a list of those to add, and then do something to check that both lists are actually in sync.

Thanks for taking the time to help, @pfaffman!

The reason we export the CVS daily is because we do not have our forum tied directly into our AD accounts. It was setup like that to allow anyone to register for an account on our forum. Even though we do not have our discourse instance tied into Active Directory authentication, will the API be able to pull the information from AD? (I was previously advised by some who do most of the developing for our forum that it would be best to have the active accounts exported from AD, then imported into the custom group… I am open to other options though.).

Thanks again!
:smiley:

Unless the computer managing the AD accounts is not connected to the internet, then it could update Discourse when changes are made to those accounts.

No. The AD server will be generating the API calls.

I think my point is that whatever code is generating the CSV file could just as easily generate the API calls necessary to do the updates.

Awesome! That’s great to know!!

I’ll ask around the 'Space (our makerspace, that is…) to see if someone can help me learn how to configure it!

Thanks again, I really appreciate it!! :smiley:

안녕하세요 @Selk68 @pfaffman, 대량 사용자 삭제에 대한 해결책을 찾고 있습니다. 스크립트를 통해 이를 수행할 수 있다는 것을 알고 있습니다. 플랫폼에서 스크립트를 실행하는 방법에 대해 더 자세한 정보를 공유해 주실 수 있을까요? 아니면 개발자만 수행할 수 있는 작업인가요?

또한 AD(Active Directory)에 대해 읽었습니다. AD가 어떻게 작동하는지, 그리고 AD를 Discourse와 동기화하는 방법에 대해서도 알려 주실 수 있을까요?
감사합니다.

관리용 일괄 작업을 참고해 보세요. 몇 가지 단서를 얻을 수 있을 것입니다.

AD가 Windows Active Directory를 의미한다면, 이미 깊이 관여하지 않았다면 사용을 피하는 것이 좋습니다. SSO로 사용할 수 있는 기능이 있을 것 같긴 하지만, 그걸 알아내기 위해서는 제게 돈을 많이 주셔야 할 겁니다.

안녕하세요 @pfaffman. 시간 내어 답변해 주셔서 감사합니다. 명령줄을 통해 행정용 일괄 작업을 살펴보겠습니다.