Announcement

Collapse
No announcement yet.

GetObject?

Collapse
X
 
  • 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).

    Code:
    'Connect to server and create user
    Set container = GetObject("WinNT://" & ServerName)
    Set user = Container.Create("User",UserName)
    	User.SetInfo
    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
    	User.SetInfo
    set User = nothing
    'Puts User in Group
    Set User = GetObject("WinNT://" & ServerName & "/" & UserName & ",User")
    Set Group = GetObject("WinNT://" & ServerName & "/" & GroupName & ",Group")
    	Group.Add(User.ADsPath)
    	Group.SetInfo
    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, 05:53 PM.
    Dominic Mitchell
    Phoenix Visual Designer
    http://www.phnxthunder.com

    Comment


    • #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? "

      Comment


      • #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.

        KISS

        A bunch of goodies

        Comment


        • #5
          To translate the script to PB, he will need ADsGetObject or ADsOpenObject.
          Dominic Mitchell
          Phoenix Visual Designer
          http://www.phnxthunder.com

          Comment


          • #6
            In case you're interested, Joe, here's the download link to the VBScript documentation: http://www.microsoft.com/downloads/d...displaylang=en

            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.

            Comment


            • #7
              Thanks Knuth!

              I'll take a look.
              Software makes Hardware Happen

              Comment

              Working...
              X