WinNT processing of objects (Domain, computer,users, and groups)

Started by oldone1, October 22, 2015, 06:57:51 AM

Previous topic - Next topic

oldone1

 
  Just a quick setup to these questions...

  I am using Winbatch on a Standalone desktop computer using Windows XP sp3.  The reason for still using XP is that I have quite a few utilities and other tools that work on Xp but may not be availale on later versions of windows.  I was creating winbatch scripts for my own use up to about 18 months ago.  At that point I got involved with something else anwas only using existing scripts.  These worked ok.  Within the last month I began to investigate the creation of new scripts, but I have not purchased a later version of Winbatch.  My version is 2014A. 

  One of my old scripts performed the following functions:

    1. Using the WinNT provider and some functions from the ADSI extender and the Win32 Network extender and the  COm extender , I created a file of ADSI paths that I have. I then was able to create a process to select one of these paths and display the properties and values of those properties for the specified object.  These paths were for domain, computer, group and user objects.  Due to the standalone workstation, the domain was actually my workgroup not a real domain.  I was able to display some properties, but not all because of WinNT not having the same capability as the ADSI provider.

    2.  As a afterthought I was able to add to this script a mechanism to modify the value for a specific property of the USER object.  This property was "FullName".  This property already existed but had no value.  A side effect of my winbatch modification was that the updated value of "FullName" was now on the WMI classes that had that property(Win32_Networkloginprofile and Win32_Useraccount).

These are the winbatch script lines used to successfully perform modification

   objUser = ObjectGet("WinNT://bacon/RUSTY2/RustyBacon")
   objUser.Put("FullName","Jabez Robert Bacon")
   objUser.SetInfo()

  I also used these script lines which also worked.

   objUser = ObjectGet("WinNT://bacon/RUSTY2/RustyBacon")
   objUser.FullName = "Jabez Robert Bacon"
   objUser.SetInfo()



    I was able to create a series of vbscripts to list the properties and their values, but did not try any modification using vbscript. 

  Now come the problems:

   When I started using winbatch again, the first "thing" was to try another modification.  I chose the computer object and a particular property.  However, I am unable to perform the modification using the same approach that I used for "FullName".  I keep getting an error that states that ADSI is not active when I am attemting to perform a SetInfo.  Of course it is not, because I am using a stand alone computer.  I believe that this is occurring because this property has been added to the Computer object  I believe that I somehow added this property and value, but I do not remember how I Did it.

  Problem # 1  How do you add a property and value to an object(in this case the computer object)?  Remember that I only have the Winnt provider.  I tried to use the dsSetProperty function from the ADSI extender , but it did not work. I hardcoded the ADSI path for the computer object both with and without the Domain object(really my workgroup).

  Problem #2   How do you modify such a property?


  Problem #3   Is it possible to modify properties on a WMI class using Winbatch, and if so how do you do it? The example that I am interested in is once again the "FullName" property on either the Win32_Networkloginprofile class or the Win32_User Account class.


Thank you for your time....

td

Quote from: oldone1 on October 22, 2015, 06:57:51 AM

  Problem # 1  How do you add a property and value to an object(in this case the computer object)?  Remember that I only have the Winnt provider.  I tried to use the dsSetProperty function from the ADSI extender , but it did not work. I hardcoded the ADSI path for the computer object both with and without the Domain object(really my workgroup).

The WinNT computer object does not have a property by the name of 'FullName'.  Using the WinNT provider you cannot change that fact.  It makes no difference if you are using COM Automation or the extender.  You can extend the an Active Directory schema to add properties but that doesn't matter since you are not using AD. 

Quote
  Problem #2   How do you modify such a property?

You assign a value to it using the WIL assignment operator (=) with COM Automation objects or call the extenders dsSetProperty whan using the extender. However, the property must exist and it must not  be marked read-only.

Quote
  Problem #3   Is it possible to modify properties on a WMI class using Winbatch, and if so how do you do it? The example that I am interested in is once again the "FullName" property on either the Win32_Networkloginprofile class or the Win32_User Account class.

If you look at MSFT's documentation for the Win32_NetworkLoginProfile class you will set that the property is marked as read-only so you can't change it:

https://msdn.microsoft.com/en-us/library/aa394221%28v=vs.85%29.aspx

On the other hand the Win32_UserAccount class's FullName property is both read and write so you can use this class to change the the property:

https://msdn.microsoft.com/en-us/library/aa394507%28v=vs.85%29.aspx

Here is a link to a Tech Database article that illustrates using the class in WIL:

http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/UDF~-~UDS~Library/Network~Related+Get~User~SID.txt


"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

oldone1

Thank very much.  I had not looked at the possibility of a Read-only situation.  I did discover that I had changed a value within the Computer Object by changing the registry via a utility program.  This utility changes the RegisteredOrganization value which is what appears in  the Division property of the Computer object.  It also changed the organization property of the WMI class Win32_operatingsystem.

td

If you look at the Win32_OperatingSystem class documentation:

https://msdn.microsoft.com/en-us/library/aa394239%28v=vs.85%29.aspx

You will see that the registry keys for some properties are documented or at least pointing to a registry area where more information can be found.   So it follows that changing the registry value, assuming you have sufficient privileges, will in some cases change the property.  But keep in mind that many properties are not directly represented in the registry.

It is also interesting that for the 'Organization' property the class documentation points to the 'Windows' key but that actual value is under the 'Windows NT' key.  And one of the downsides of changing values like this in the registry is that the location and even the name can change from version to version of Windows.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade