Novell Home

Automatic Login and Logout for Testing ZENworks Configuration Management Policies for Windows

Novell Cool Solutions: Feature
By Rajesh Lingam, Vijay Kumar Kunchakuri

Digg This - Slashdot This

Posted: 11 Sep 2007
 

Ever wish you had an easy way to perform a Login and Logout operation on a Windows Managed Device over a period of time without manual intervention? Check out this great solution from Novell engineers Lingam Rajesh and Vijay Kumar Kunchakuri.

While working with ZENworks Configuration Management (ZCM) policies for Windows in a test setup or customer lab environment, you may wish to perform a repetitive login and logout operation in order to test the reliability of your User and Device-based policies, such as a Dynamic Local User (DLU) Policy.

This Cool Solution will help you in performing a repetitive login and logout on the managed device over a specified period of time without any manual intervention. The solution basically utilizes the RDP tool available with a Windows Operating System.

  1. Create RDP Configuration file:
    1. Launch the Remote Desktop Connection on a Windows device.




    2. Input the Computer, Username, Password, Domain and select the Save my Password option. The Username and Password here should be the same as the eDirectory credentials if you are testing a DLU Policy.




    3. Click "Save As..." and save the above settings into a .rdp configuration file.



      Note: You can manually edit the configuration file (except for the password which will be in an encrypted form). Hence when the password changes, you need to recreate this .rdp configuration file.


  2. Launch RDP Console Session:

    To launch an RDP Console Session from the DOS Command Line, use the following Command:

    C:\ mstsc \console <Path_To_RDP_Configuration_File>

    For instance, C:\ mstsc \console C:\Documents and Settings\lrajesh\My Documents\RDP_Configuration\lrajesh.rdp

    Also, since this would be Session 0 on the device, ensure that there are no Users logged onto the physical device.


  3. Automatic Logout from RDP Console Session:
    1. Create a .bat (batch) file on the Windows Managed Device where the ZCM Adaptive Agent is installed.
    2. To perform certain operations in the above console session and then to logout from the device automatically, edit the content of the batch file to be something like the following and save it on the device.

      ping -n <No_of_Pings> <Any_IP_Address>   [For ex: ping -n 30 164.99.157.143]
      	zac refresh
      	zac policy-list
      	... 
      	...  [some more operations of user choice]
      	logoff  [Include this as the last statement in the batch file to affect an automatic logout of the RDP Console Session]


    3. Add this batch file to the Windows Registry as a new String Value, so that the above tasks get executed as soon as the User logs in to the device.


    4. The path to the Windows Registry is, HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
  4. Automate the whole process:
    1. A perl script or a batch file should be created to do the above operations, viz., launching RDP console session to the device, performing certain user required operations on the device and then automatically logging out from the device repeatedly, at regular intervals of time.


    2. The perl script which we have come up with is:
      ###################################Perl Script to Automate Windows Login And Logout#################################
      
      #!C:\perl\bin\perl
      
      ## Name :  Rajesh Lingam
      ## Title   :  Auto login and logout on a Windows Device
      
      $c=100;     # Number of times user wants to login and logout of the Windows Device
      $i=1;
      
      print "No of times the login and logout process passed: \n";
      
      while($c)
      {
      
      	`mstsc  \console C:\Documents and Settings\lrajesh\My Documents\RDP_Configuration\lrajesh.rdp`;
      	print $i;
      	print "\n";
      	$c--;  # Decrimenting the count by one  
      	$i++;
      	sleep 900; # Time duration in seconds, between each logout and the next login to the device.
      	wait;
      	
      }
      
      
      ################################################################################################################


Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

© 2014 Novell