Creation date of an user

it’s possible to know the date of creation of an user via shell?

[root@server Template]# db accounts show minucci
minucci=user
City=
Company=
Department=
FirstName=Carlo
LastName=Minucci
MailForwardStatus=disabled
MailQuotaType=default
MailSpamRetentionStatus=disabled
MailStatus=enabled
PassExpires=yes
PhoneNumber=
Samba=enabled
Shell=/usr/libexec/openssh/sftp-server
Street=
Uid=5475
__state=active
[root@server Template]#

with db account command there is not this information
i need to found all user old more than 5 years then delete it

how can you have an 5 years old account on NS? :slight_smile:

ok… 3 years? :slight_smile:

This query searches for all users and print the related creation timestamp:
ldapsearch -Y EXTERNAL '(objectClass=posixAccount)' createTimestamp

If you wish to check the condition directly into ldap query, ake a look at this: http://stackoverflow.com/questions/19021421/user-account-creation-date-in-ldap

3 Likes

ok! this work but… don’t work

i try to explain

[root@server etc]# ldapsearch -Y EXTERNAL β€˜(objectClass=posixAccount)’ createTimestamp | tr -d β€œ\n” | tr -s β€œ#” β€œ\n” | grep People | awk β€˜{print $5 " " $1}’ | grep minucci
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
20150825100712Z minucci,

i search for my username
but if i search for an username create now, don’t work

[root@server etc]# ldapsearch -Y EXTERNAL β€˜(objectClass=posixAccount)’ createTimestamp | tr -d β€œ\n” | tr -s β€œ#” β€œ\n” | grep People | awk β€˜{print $5 " " $1}’ | grep sostegno
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0

but user exist

[root@server etc]# db accounts show sostegno
sostegno=user
City=
Company=
Department=
FirstName=Corso
LastName=Sostegno
MailForwardStatus=disabled
MailQuotaType=default
MailSpamRetentionStatus=disabled
MailStatus=enabled
PassExpires=yes
PhoneNumber=
Samba=enabled
Street=
Uid=6096
__state=active

in other way

[> root@server etc]# getent passwd | grep minucci

minucci:x:5475:5475:Carlo Minucci:/var/lib/nethserver/home/minucci:/usr/libexec/openssh/sftp-server
[root@server etc]# getent passwd | grep sostegno
[root@server etc]#

an again

[root@server etc]# ldapsearch -Y EXTERNAL β€˜(objectClass=posixAccount)’ createTimestamp | tr -d β€œ\n” | tr -s β€œ#” β€œ\n” | wc -l
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
508
[root@server etc]# db accounts print | wc -l
1811
[root@server etc]# db accounts print | grep user | wc -l
836
[root@server etc]#

it’s a problem in my mind? :slight_smile:

1 Like