[tech] Script to assist with AD/LDAP lookups for /away/du

Dylan Hicks dylanh333 at ucc.gu.uwa.edu.au
Tue Dec 27 01:26:26 AWST 2022


Hi All,

I've had one of those late-night surges of motivation, and managed to whip up a script that:
(1) Parses the latest disk usage statistics for "/away" from "/away/du/du.today";
(2) Treats the filename portion of each path in this report as a username;
(3) Looks up this username via `ldapsearch`;
(4) Calculates (in a human-readable format) things like whether or not the account is enabled and the date they last logged on; and finally
(5) Outputs all this (including the original `du` output) on a per-user basis in a quasi-LDIF format.

If any of the above is jargon and doesn't make sense to you, here's an example of what this output looks like:
```
dn: CN=nick,CN=Users,DC=ad,DC=ucc,DC=gu,DC=uwa,DC=edu,DC=au
displayName: Nick Bannon
userAccountControl: 66048
lastLogonTimestamp: 133153150606203480
accountDisable: 0
lastLogonDate: Mon 12 Dec 18:37:40 AWST 2022
du: 1.9G        /space/away/home/wheel/nick
```

The script that generates this output is here: "/away/du/stats-lookup-accounts.sh"
A file with the generated output is here: "/away/du/du.ldap.20221227"

Anyway, I'll (hopefully) plug away at some of this output over the course of this week and find some more candidate away directories to clean up.
If not, hopefully this is also useful to anyone else who feels like freeing up some space!

--
Kind regards,
Dylan Hicks [333]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ucc.gu.uwa.edu.au/pipermail/tech/attachments/20221227/9322d98d/attachment.htm>


More information about the tech mailing list