No announcement yet.


  • Filter
  • Time
  • Show
Clear All
new posts

  • GetObject?

    Given the following (vbs?) script, does anyone know where the calls to GetObject(" comes from? Looking through the Win32API help file, I see "GetObject" but it appears to be for graphic files only. Any ideas out there?

    (What I'm trying to do is add user accounts to a local Windows PC).

    'Connect to server and create user
    Set container = GetObject("WinNT://" & ServerName)
    Set user = Container.Create("User",UserName)
    set container = nothing
    set user = nothing
    'Sets Pass, Change Pass at Next Login and Password Never Expires
    Set User = GetObject("WinNT://" & ServerName & "/" & UserName & ",User")
    	Call User.SetPassword(Password)
    	User.Put "PasswordExpired", 0	'0 = NOT SET User must change pass at next login 1 = SET User must change pass at next login
    	Flags = User.Get("UserFlags")
    	User.Put "UserFlags", Flags XOR &H10000
    set User = nothing
    'Puts User in Group
    Set User = GetObject("WinNT://" & ServerName & "/" & UserName & ",User")
    Set Group = GetObject("WinNT://" & ServerName & "/" & GroupName & ",Group")
    set User = nothing
    set Group = nothing
    Software makes Hardware Happen

  • #2
    The Win32API help file will be of no use here.
    This is COM, and it looks like the Active Directory Service.
    The Active DS Type Library.
    Last edited by Dominic Mitchell; 8 May 2008, 06:53 PM.
    Dominic Mitchell
    Phoenix Visual Designer


    • #3
      I Agree Dominic..the code is DEFINITELY OLE...although unsure if VB6 or VBA (Code shown insufficient)

      I know there is code via API that does the same (but the thought eludes me at the moment)...Joe, I think what you need to search for is User Accounts/Settings and avoid anything involving OCX or ActiveX at all costs if you can.

      (I am sure someone will help with the API solution, but been a long day for me to think back how things "Used to work" vs the caveats of what M$ has now changed)
      Engineer's Motto: If it aint broke take it apart and fix it

      "If at 1st you don't succeed... call it version 1.0"

      "Half of Programming is coding"....."The other 90% is DEBUGGING"

      "Document my code????" .... "WHYYY??? do you think they call it CODE? "


      • #4
        GetObject is similar to CreateObject and retrieves an instance of an Automation object from a file or progID.. This gives you access to an object that already exists somewhere on your computer as opposed to creating the little rascal first.

        You may find something useful here Joe.


        A bunch of goodies


        • #5
          To translate the script to PB, he will need ADsGetObject or ADsOpenObject.
          Dominic Mitchell
          Phoenix Visual Designer


          • #6
            In case you're interested, Joe, here's the download link to the VBScript documentation:

            Even if you don't need it for this problem anymore, VBScript is a very nice addition in a systems administrator's toolbox. Plain text files that just "execute", but much more powerfull than BAT/CMD files.


            • #7
              Thanks Knuth!

              I'll take a look.
              Software makes Hardware Happen