Re: Add domain user to local group script troubleshoot
From: Richard Mueller [MVP] (rlmueller-NOSPAM_at_ameritech.NOSPAM.net)
Date: 03/25/04
- Next message: Sudeep: "Re: Script to search for a User's OU in Active Directory"
- Previous message: Torgeir Bakken \(MVP\): "Re: Identifying the User Logged on to a Remote Computer - not always working"
- In reply to: mtothej: "Add domain user to local group script troubleshoot"
- Next in thread: Rick Kalifa: "Re: Add domain user to local group script troubleshoot"
- Reply: Rick Kalifa: "Re: Add domain user to local group script troubleshoot"
- Reply: mtothej: "Re: Add domain user to local group script troubleshoot"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 24 Mar 2004 23:05:41 -0600
mtothej wrote:
> I am trying the following script to add a domain user to a local group:
>
> Set objGroup = GetObject _
> ("WinNT://remotecomputer/Administrators")
> Set objUser = GetObject _
> ("LDAP://CN=username,OU=MyOU,OU=MyOU,DC=root,DC=mydomain,DC=org")
> objGroup.Add(objUser.ADsPath)
>
> I get the following error:
>
> C:\Scripts\add_domain_user_to_local_group.vbs(5, 1) Active Directory: An
invalid
> Active Directory pathname was passed
>
> I know the ADsPath for the user is correct because I can retrieve
properties from it. I know the objGroup path is correct because I can
enumerate the current users in the group.
>
> Is something wrong in the last line? Am I on the right track or is there
another way to add a domain user to a local group? Thanks :)
You must bind to the user object with the WinNT provider. If the
"cn=Username" user has sAMAccountName equal to "username", and the NetBIOS
name of the domain is "MyDomain", then use
Set objUser = GetObject("WinNT://MyDomain/username,user")
The local group object's Add method does not understand an LDAP AdsPath.
-- Richard Microsoft MVP Scripting and ADSI HilltopLab web site - http://www.rlmueller.net --
- Next message: Sudeep: "Re: Script to search for a User's OU in Active Directory"
- Previous message: Torgeir Bakken \(MVP\): "Re: Identifying the User Logged on to a Remote Computer - not always working"
- In reply to: mtothej: "Add domain user to local group script troubleshoot"
- Next in thread: Rick Kalifa: "Re: Add domain user to local group script troubleshoot"
- Reply: Rick Kalifa: "Re: Add domain user to local group script troubleshoot"
- Reply: mtothej: "Re: Add domain user to local group script troubleshoot"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|