#62141 - 2002-03-11 02:51 PM
Re: Script for determining NT account expiry?
|
attiahia
Hey THIS is FUN
Registered: 2000-03-27
Posts: 268
|
NTDOC
thanks a lot for your hlp. The value of the mentioned key in my workstation is 5,0,00,0 which mean Windows 2000/DSClient.
LLigetfa
Your idea is excellent and this what I already start to do but before I continue I like to say the following.
This code
$usr = GetObject("WinNT://"+@LDOMAIN+"/"+@UserID+",user") $AccountExpirationDate = $usr.AccountExpirationDate ? @UserID+" - AccountExpirationDate = "+$AccountExpirationDate
Is exactly what I want and it gave me the expiration date but the question is:
When I tested the code locally (C:\Kix32 Script.Kix) on one of our user BC it did not work because the BC does not have ADSI. Now, in the real situation when I place this script on the domain controller where ADSI is installed, will the script work fine?
I mean is there a way to run this part of the script on the domain controller?
Or this code require ADSI to be installed on the user BC it self?
Thanks a lot For this great help. ![[Smile]](images/icons/smile.gif) [ 11 March 2002, 14:53: Message edited by: attiahia ]
|
|
Top
|
|
|
|
#62143 - 2002-03-14 03:25 PM
Re: Script for determining NT account expiry?
|
attiahia
Hey THIS is FUN
Registered: 2000-03-27
Posts: 268
|
LLigetfa I received great support from you. Thank you and thanks for every one.
|
|
Top
|
|
|
|
#62144 - 2002-03-18 06:47 AM
Re: Script for determining NT account expiry?
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
I was playing around with the AccountExpirationDate properties and found that a failure to resolve $user.AccountExpirationDate properly can invalidate an entire string that was to be printed to the screen. This behavior somewhat surprised me and can be demonstrated using the following code. The basic issue that this teaches is all COM calls should be fed into variables and NOT concatenated into a string using a plus sign.
When you execute this code, the text "ExpDate2" is not printed at all when the account is configured NOT to expire. The call $User.AccountExpirationDate returns an error apparently nullifying the entire string.
I do not believe that this is an issue that needs any resolution. I bring it up so that everyone is aware that using a plus sign (+) in these circumstances can potentially cause them a problem.
To test: ; Setup User1 with account set to NEVER expire. ; Setup User2 with an account set to Expire on some date ; Be sure to configure a Fullname for each account to verify that the script continues to run properly. ; Execute with USER1, edit then execute for User2
$User = GetObject("WinNT://@Ldomain/User1,user")
? "Name: " + $User.name ? "ExpDate1: " $User.AccountExpirationDate ? "ExpDate2: " + $User.AccountExpirationDate $Date = $User.AccountExpirationDate ? "ExpDate3: $Date" ? "Error:@Error@CRLF@Serror" ? "FullName: " + $User.fullname [ 18 March 2002, 14:59: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 931 anonymous users online.
|
|
|