EPrints Technical Mailing List Archive

See the EPrints wiki for instructions on how to join this mailing list and related information.

Message: #08909


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

Re: [EP-tech] command line user delete?


CAUTION: This e-mail originated outside the University of Southampton.

Hi Herbert,
Here's something that should help:
https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgist.github.com%2Fjesusbagpuss%2Fd5fa10ef3915e036f0eb24b4a2ad019f&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C0479d428654b4bdcc08808da0db731a1%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637837378283290569%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=orvVv0j%2Bmz492WxjRpO2RuP5v6uEv7GSFgXhiyxs2DE%3D&amp;reserved=0

Save it as:
[EPRINTS_ROOT]/bin/local/delete_user
And run it:
[EPRINTS_ROOT]/bin/local/delete_user ARCHIVEID USERID [USERIDx USERIDy ...]

It provides a summary of user details:
 Name; usertype;  email;  joined date

It also outputs whether the user:
- has any current login tickets
- owns any EPrints
- is a contact for any eprints

By default it will ask you to confirm each user deletion.
It won't stop you deleting a user that owns EPrints, is currently logged in, or is a contact for EPrints.

Please let me know if you have any questions... and run it on a test instance first! :)

Cheers,
John


-----Original Message-----
From: eprints-tech-bounces@ecs.soton.ac.uk [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of Herbert Hrachovec via Eprints-tech
Sent: 23 March 2022 15:55
To: eprints-tech@ecs.soton.ac.uk
Subject: Re: [EP-tech] command line user delete?

CAUTION: This e-mail originated outside the University of Southampton.

Thank you all for your help and comments.

I understand that it is tricky to remove users. But before installing a
chaptcha I had a numnber of bots register with fake addresses. Even
though they cannot go on from there, they do not belong in the
database. I promise I'll be careful trying John's script ...

Best regards,
h.h.

Am Wed, 23 Mar 2022 10:42:39 +0000
schrieb John Salter via Eprints-tech <eprints-tech@ecs.soton.ac.uk>:

> CAUTION: This e-mail originated outside the University of Southampton.
>
> Hi Herbert,
> You can also add a line something like this:
>     my $item_count = $user->owned_eprints_list( dataset =>
> $user->repository->dataset( "eprint" ) )->count; This will show how
> many EPrints the user owns.
>
> I've got a GDPR related user clean-up script that also checks for
> other aspects such as:
> - joined date
> - if the account has been activate
> - last login time
> - if the account owns any eprints
> - if the email address matches the contact_email for any items (can
> be part of the Request a Copy process)
>
> I will share this on GitHub later (once I add some comments to it :)
>
> Cheers,
> John
>
> -----Original Message-----
> From: eprints-tech-bounces@ecs.soton.ac.uk
> [mailto:eprints-tech-bounces@ecs.soton.ac.uk] On Behalf Of Florian
> Heß via Eprints-tech Sent: 23 March 2022 10:31 To:
> eprints-tech@ecs.soton.ac.uk Subject: Re: [EP-tech] command line user
> delete?
>
> CAUTION: This e-mail originated outside the University of Southampton.
>
> Hi Herbert,
>
> even though there is not an appropriate script in the official
> distribution of E-Prints, consider yourself free to try to forge a
> perl "one-liner" like this, that just uses the API:
>
> eprintsuser:~ $ perl -Iperl_lib -MEPrints -E 'my $E = EPrints->new; my
> $R = $E->repository("INSERT_REPO_ID_HERE");
> $R->dataset("user")->search(search_fields => [{ meta_fields =>
> ["username"], match => "EQ", merge => "ANY", value => "gone leftoo"
> }])->map(sub { say "Type of user ", $_[2]->value("username"), " is ",
> $_[2]->value("usertype") });'
>
> The upper quick and dirty demo code is deliberately non-destructive.
> Once you replace the say-statement by $_[2]->delete I hope you have
> double-proofread the given list of user names.
>
>
> Regards
>
> Florian Heß
>
> Am 23.03.22 um 10:01 schrieb David R Newman via Eprints-tech:
> > Hi Herbert,
> >
> > I am not aware of anyway of programmatically removing a user from
> > the command line.  There is the EPRINTS_PATH/bin/toolbox that can do
> > standard API like operations but only for eprints, documents and
> > files, including delete in a way similar to how you may intend for
> > these spurious users.  It may be possible to extend this but would
> > need to be done with care.
> >
> > I assume in your scenario they are unused user accounts with no
> > eprints associated.  These would be safe to delete but those with
> > eprints would need to have a mechanism for reassigning them or at
> > least confirm the person using the command is happy for them to be
> > deleted as well.  I think this is probably why there is no command
> > line tool to do this, as it could be rather dangerous.
> >
> > Regards
> >
> > David Newman
> >
> > On 23/03/2022 7:29 am, Herbert Hrachovec via Eprints-tech wrote:
> >> CAUTION: This e-mail originated outside the University of
> >> Southampton.
> >>
> >> Hello,
> >>
> >> is there a way to delete spurious users on the command line e.g. by
> >> their UID? (I've had some of them.)
> >>
> >> Best regards,
> >> h.h.
> >>
> >> ***
> >> Options:https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmailman.ecs.soton.ac.uk%2Fmailman%2Flistinfo%2Feprints-tech&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C0479d428654b4bdcc08808da0db731a1%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637837378283290569%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=yb9Ywvi11EerCPX0kmjnyf7RV8e1ZUqVcBmsoCcSVsw%3D&amp;reserved=0
> >> ***
> >> Archive:https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.eprints.org%2Ftech.php%2F&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C0479d428654b4bdcc08808da0db731a1%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637837378283290569%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=DgL733QeFbnPt0edwleVjzmDd%2BzM%2BY8wU00fATnQ3lU%3D&amp;reserved=0
> >>
> >> *** EPrints community
> >> wiki:https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwiki.eprints.org%2F&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C0479d428654b4bdcc08808da0db731a1%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637837378283290569%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=yWjLvAvcc%2F9pff6%2FJZ%2BEmWLfriUEAMO0eq3kz5u%2Bd7s%3D&amp;reserved=0
> >>
> >
> > *** Options:
> > https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmailman.ecs.soton.ac.uk%2Fmailman%2Flistinfo%2Feprints-tech&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C0479d428654b4bdcc08808da0db731a1%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637837378283290569%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=yb9Ywvi11EerCPX0kmjnyf7RV8e1ZUqVcBmsoCcSVsw%3D&amp;reserved=0
> > *** Archive:
> > https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.eprints.org%2Ftech.php%2F&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C0479d428654b4bdcc08808da0db731a1%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637837378283290569%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=DgL733QeFbnPt0edwleVjzmDd%2BzM%2BY8wU00fATnQ3lU%3D&amp;reserved=0
> > *** EPrints community wiki:
> > https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwiki.eprints.org%2F&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C0479d428654b4bdcc08808da0db731a1%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637837378283290569%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=yWjLvAvcc%2F9pff6%2FJZ%2BEmWLfriUEAMO0eq3kz5u%2Bd7s%3D&amp;reserved=0
> >
>
> --
> UB Heidelberg (Altstadt)
> Plöck 107-109, 69117 HD
> Abt. Informationstechnik
> https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.ub.uni-heidelberg.de%2F&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C0479d428654b4bdcc08808da0db731a1%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637837378283290569%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=nF7Ne58%2BpGVnK5y9NhMVyESff%2Ffqy8GmZuZImYqbATk%3D&amp;reserved=0
>
> *** Options:
> https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmailman.ecs.soton.ac.uk%2Fmailman%2Flistinfo%2Feprints-tech&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C0479d428654b4bdcc08808da0db731a1%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637837378283290569%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=yb9Ywvi11EerCPX0kmjnyf7RV8e1ZUqVcBmsoCcSVsw%3D&amp;reserved=0
> *** Archive:
> https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.eprints.org%2Ftech.php%2F&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C0479d428654b4bdcc08808da0db731a1%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637837378283290569%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=DgL733QeFbnPt0edwleVjzmDd%2BzM%2BY8wU00fATnQ3lU%3D&amp;reserved=0
> *** EPrints community wiki:
> https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwiki.eprints.org%2F&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C0479d428654b4bdcc08808da0db731a1%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637837378283290569%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=yWjLvAvcc%2F9pff6%2FJZ%2BEmWLfriUEAMO0eq3kz5u%2Bd7s%3D&amp;reserved=0
>
> *** Options:
> https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmailman.ecs.soton.ac.uk%2Fmailman%2Flistinfo%2Feprints-tech&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C0479d428654b4bdcc08808da0db731a1%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637837378283290569%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=yb9Ywvi11EerCPX0kmjnyf7RV8e1ZUqVcBmsoCcSVsw%3D&amp;reserved=0 ***
> Archive: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.eprints.org%2Ftech.php%2F&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C0479d428654b4bdcc08808da0db731a1%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637837378283290569%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=DgL733QeFbnPt0edwleVjzmDd%2BzM%2BY8wU00fATnQ3lU%3D&amp;reserved=0 *** EPrints community wiki:
> https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwiki.eprints.org%2F&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C0479d428654b4bdcc08808da0db731a1%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637837378283290569%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=yWjLvAvcc%2F9pff6%2FJZ%2BEmWLfriUEAMO0eq3kz5u%2Bd7s%3D&amp;reserved=0


*** Options: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmailman.ecs.soton.ac.uk%2Fmailman%2Flistinfo%2Feprints-tech&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C0479d428654b4bdcc08808da0db731a1%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637837378283290569%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=yb9Ywvi11EerCPX0kmjnyf7RV8e1ZUqVcBmsoCcSVsw%3D&amp;reserved=0
*** Archive: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.eprints.org%2Ftech.php%2F&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C0479d428654b4bdcc08808da0db731a1%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637837378283290569%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=DgL733QeFbnPt0edwleVjzmDd%2BzM%2BY8wU00fATnQ3lU%3D&amp;reserved=0
*** EPrints community wiki: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwiki.eprints.org%2F&amp;data=04%7C01%7Ceprints-tech%40ecs.soton.ac.uk%7C0479d428654b4bdcc08808da0db731a1%7C4a5378f929f44d3ebe89669d03ada9d8%7C0%7C0%7C637837378283290569%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=yWjLvAvcc%2F9pff6%2FJZ%2BEmWLfriUEAMO0eq3kz5u%2Bd7s%3D&amp;reserved=0