How to get user password expiration from Active Directory?

people!

There is an Active Directory (Windows) and a Samba Linux client. In Active Directory, the policy has been adjusted so that users periodically change their passwords (passwords have an expiration date).

My question is pretty simple: can I get this expiration time for a given user if I work on a Linux machine with Samba?

+4
source share
2 answers

It depends on the configuration of the domain controller. You may try:

net ads user info USERNAME@DOMAIN.COM -S DC_SERVER_NAME -U USERNAME

USERNAME@DOMAIN.COM - , DC_SERVER_NAME - , USERNAME - .

.

, ,

ads_pull_uint32 failed

UNIX- .

, Microsoft Windows Services UNIX, .

. , .

: 80 , (smbpasswd -U USERNAME -r DC_SERVER_NAME), 90 . , .

[] rpcclient, script:

#!/bin/bash
# author: Tim Wahrendorff 2016
# licence: Public Domain - https://wiki.creativecommons.org/wiki/Public_domain
# 
# To use this script you need at least: 
# sudo apt-get install libnotify-bin rpcclient
#
# Please set your account, password and domaincontroller to use this script


USER="username" # Domain accountname
PASS="Pa$$W0rd" # Domain password
DC="vmdc01"     # Domaincontroller

### START RPCCLIENT query
if [ "x$USERDCID" == "x" ]; then
    RPCLOOKUPID=$(rpcclient -U $USER%$PASS -c "lookupnames $USER" $DC 2> ./rpc_errFile)

    USERDCID=$(echo "$RPCLOOKUPID" | grep -e '[0-9]\{4,9\} ' -o)
fi

QUERYUSER=$(rpcclient -U $USER%$PASS -c "queryuser $USERDCID" $DC 2> ./rpc_errFile)

EXPDATE=$(echo "$QUERYUSER" | grep 'Password must change Time' | grep -e '[a-Z]\{2\}, [0-9]\{2\} [a-Z]\{3\} [0-9]\{4\} [0-9]\{2\}:[0-9]\{2\}' -o)

## Load rpc error Message
RPCERR=$(<./rpc_errFile)

## send notifications to Unity Desktop
if [ "x$RPCERR" != "x" ]; then
    notify-send -i /usr/share/icons/gnome/48x48/status/dialog-error.png "Error while fetching expiration date of your domain password" "$RPCERR"    
else
    notify-send -i /usr/share/icons/gnome/48x48/status/dialog-information.png "your domain password expires at " "$EXPDATE h"
fi

### END RPCCLIENT query

script , , Unity. , script, .

[/]

+4

kerberos, ADpassword - python .

ADpassword GitHub

0

Source: https://habr.com/ru/post/1622894/


All Articles