{$X+,B-,V-} {essential compiler directives}

Program CexpPw;

{ Example for the nwConn unit / NwTP 0.6 API. (c) 1993,1995, R. Spronk }

{ Andre Middendorp [2:512/220] wrote on Sun 3 Jul 94

Q: Ik ben op zoek naar een tooltje waarmee ik op een NW 3.1x server
   een file aan kan maken met daarin alle gebruikers waarvan het
   wachtwoord is vervallen. Wie weet iets....?

A: Here's a short program that will check whether or not the password
   has expired of any user object. It will present you with a list of
   all accounts that are expired.}

Uses nwMisc,nwBindry,nwConn,nwServ;
 { nwServ used for GetFileServerDateAndTime only }

{ Demonstates the GetObjectLoginControl function.
  see also the information provided with the ObjectCanLoginAt call }

Var TimeNow         :TnovTime;
    lastObjSeen     :Longint;
    RepName         :String;
    RepType         :Word;
    RepId           :LongInt;
    RepFlag         :Byte;
    RepSecurity     :Byte;
    RepHasProperties:Boolean;
    LogControlInfo  :TloginControl;
    NbrOfExp        :word;
Begin
Writeln('CEXPPW: Check Expired Passwords.');
IF NOT (IsShellLoaded and IsUserLoggedOn)
 then begin
      writeln('Load network shell and logon before running this program');
      halt(1);
      end;

GetFileServerDateAndTime(TimeNow);

NbrOfExp:=0;
lastObjSeen:=-1;
WHILE
ScanBinderyObject('*',OT_USER,lastObjSeen,
                  RepName, RepType, RepId,
                  RepFlag, RepSecurity, RepHasProperties)
 do begin
    IF GetObjectLoginControl(RepName,RepType,LogControlInfo)
     then with LogControlInfo.AccountExpirationDate
           do if (year>0) { year=0: no expiration date was set }
                 and (TimeNow.year>=year)
                 and (TimeNow.month>=month)
                 and (TimeNow.day>=day)
               then begin
                    writeln('Account of ',Repname,' expired on: ',day,'/',month,'/',year);
                    inc(NbrOfExp);
                    end;
    end;
if nwBindry.Result<>$FC { NO_SUCH_OBJECT, indicates end of search }
 then writeln('Error scanning bindery : $',HexStr( nwBindry.Result,2));
if NbrOfExp=0
 then writeln(#10#13,'No expired passwords found.')
 else writeln('(dates expressed in dd/mm/yy format.');
end.
