Re: If possible to add domain user to a workstation's local administrators group by scrpting?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thanks for all yr help.

But Richard,in my script I have already get a domain user account SID
through OpenDSObject function, of course the script was running on a
workgroup rather than a domain member server.

But the problem is, when I pass the objDomainUser to objLocalGroup.add (this
is the recommended way to add a domain obj to local group), seems it
couldn't open objDomainUser.ADsPath from current xecurity naming contex.

I think the problem was objLocalGroup.add itself.
Any ideas else?

"Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx> wrote in
message news:uK6JeSFiIHA.4076@xxxxxxxxxxxxxxxxxxxxxxx
jogging wrote:

I am wondering if possible to add domain user to a workstation's local
administrators group by scrpting.

You konw, in most scenario we use {objLocalGroup}.add function to achieve
this target, but what if a workgroup?
When I try this on workgroup, script prompts fails with "unknow user name
or bad password".

You can add a domain user to a local group if you are authenticated to the
domain. Otherwise, the domain object cannot be found.

If you are logged into another computer joined to the domain, and you are
authenticated to the domain, perhaps you can use alternate credentials to
bind to the workgroup computer. Otherwise, if you are authenticated to the
workgroup computer, perhaps you can use alternate credentials to bind to
the domain object. For example:
======
Const ADS_SECURE_AUTHENTICATION = &H1
Const ADS_USE_ENCRYPTION = &H2

strUser = "MyAdmAcct"
strPassword = "xyz321q"

Set objNS = GetObject("WinNT:")
Set objDomainUser = objNS.OpenDSObject("WinNT://MyDomain/JimSmith,user", _
strUser, strPassword, _
ADS_SECURE_AUTHENTICATION Or ADS_USE_ENCRYPTION)
===========
You can use similar code to bind to a local object remotely while
authenticated to the domain. The ADsPath would specify the NetBIOS name of
the local computer rather than that of the domain.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--




.



Relevant Pages

  • ADSI Impersonation Problem
    ... Execute it by Domain User on the Domain joined PC, the script works. ... Execute it by Domain user which use the Runas command on the WorkGroup PC, ... Dim ComputerName ...
    (microsoft.public.windows.server.active_directory)
  • Re: PC communication on wireless network?
    ... How can I share files between workgroup computer and domain/workgroup ... I also use Win 2000/XP laptop at work with domain network. ...
    (microsoft.public.windowsxp.network_web)
  • Re: PC communication on wireless network?
    ... How can I share files between workgroup computer and domain/workgroup ... I also use Win 2000/XP laptop at work with domain network. ...
    (microsoft.public.windows.server.networking)
  • Re: Multiple Connections
    ... How can I share files between workgroup computer and domain/workgroup ... I also use Win 2000/XP laptop at work with domain network. ... Deepening on your network setup, you may 1) Logon local laptop using the ...
    (microsoft.public.windowsxp.network_web)
  • Re: domain / workgroup login problem
    ... How can I share files between workgroup computer and domain/workgroup ... I also use Win 2000/XP laptop at work with domain network. ... > my works laptop runs 2000 and when in the office, its configured to login ...
    (microsoft.public.win2000.security)