4 Replies Latest reply on Nov 5, 2013 3:27 PM by jameswright

    Deleting Multiple Users


      Can anyone give insight on deleting multiple users? I've tried several of the firebug suggestions offered in other discussions but have not been able to get any to work.


      Needing to delete about 6K users...you can imagine the time it would take to click through one-by-one in the admin console.


      Thanks for any help!

        • Re: Deleting Multiple Users

          Assuming you have a way to identify the users, or you just want to delete them all. You could accomplish this through the rest APIs. Forexample, I use Xquery:


          Here is an XQuery example which will delete all users with the 'gis' tag. First declare a basic module for operating against jive's API. Here is all the parts you will need for your operation.



          module namespace jive = 'http://seu.jive.com';


          declare function jive:request-template($username as xs:string, $password as xs:string) as node() {

            <http:request username="{$username}" password="{$password}" send-authorization="true" override-media-type="text/plain" method="get" />



          declare function jive:get-all-items($request-template as node(), $baseURI as xs:string) {

            let $response :=



                  jive:modify-request-template($request-template, 'GET'), $baseURI)[2])

            return ($response/list/value, if($response/links/next) then (jive:get-all-items($request-template, $response/links/next)) else ())   



          declare function jive:modify-request-template($request-template as node(), $method as xs:string, $body as node()) as node() {

             if($request-template/@method != $method) then (

                 copy $request-template-copy := $request-template

                 modify (replace value of node $request-template-copy/@method with $method,

                 insert node $body into $request-template-copy)

                 return $request-template-copy

             )   else ($request-template)



          declare function jive:modify-request-template($request-template as node(), $method as xs:string) as node() {

            jive:modify-request-template($request-template, $method, <http:body media-type="text/plain"></http:body>)



          declare function jive:process-response($responseBody as xs:string) as node() {

            json:parse(fn:replace($responseBody, "throw.*;\s*", ""))



          declare function jive:delete-item($request-template as node(), $uri as xs:string) as node() {



                 jive:modify-request-template($request-template, 'DELETE'), $uri)[2])



          Everything above would generally be in a module for re-use... Here is what the specific query would be:



          import module namespace jive = 'http://seu.jive.com';


          let $baseURI := 'localhost:8080'

          let $request := jive:request-template("login", "pass")

          let $usersToDelete := jive:get-all-items($request, $baseURI || '/api/core/v3/people?filter=tag(gis)') return

          for $user in $usersToDelete return

               jive:delete-item($request, $user/resources/self/ref)

          Note: How I use the v3 api filters to get the correct list of users to delete.


          You can use any XQuery engine you like. I use BaseX, which is free and open source. You can find it here.


          First, be carefull!.. Read up on how to import 'modules' and import the above module. Then copy the delete-gis-users.xq text above into the query editor and hit run... wait a while and all your users will be gone. For more fine grained control. I would suggest a more advanced module. However this was simplified too answer your question. Hopefully this does the trick.