Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Adding a user to groups via dsadd

Reply
 
Old 06-04-2009   #1 (permalink)
MattW


 
 

Adding a user to groups via dsadd

HI all. I'm trying to modify an HTA that I have to list user groups
for a user, and get it to add another user to each of those groups.
Here's what I've got so far:

Code:
<HTML>
<HEAD>
<TITLE>Users Group Migration HTA</TITLE>
<HTA:APPLICATION
ID="MyApp"
APPLICATIONNAME="Template"
BORDER="thick"
BORDERSTYLE="complex"
CAPTION="yes"
CONTEXTMENU="no"
ICON="http://Your URL/your icon.ico"
INNERBORDER="yes"
MAXIMIZEBUTTON="yes"
MINIMIZEBUTTON="yes"
NAVIGABLE="no"
SCROLL="no"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
VERSION="1.0"
WINDOWSTATE="maximized"/>
</HEAD>

<SCRIPT Language="VBScript">

Sub Window_onLoad
window.resizeTo 640, 480
End Sub

Sub ExitProgram
window.close()
End Sub

' Constants for the NameTranslate object.
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1


set WshNetwork = CreateObject("Wscript.Network")
strUserName1 = WshNetwork.UserName
strUserDomain = WshNetwork.UserDomain

' Specify the NetBIOS name of the domain.
strNetBIOSDomain = "Suddenlink"

Sub btnRun_Click

sUser1 = User1.value
sUser2 = User2.value
' Set sDomain = objNetwork.UserDomain
set objUser = GetObject("WinNT://" & strUserDomain & "/" & sUser1)
set objUser2 = GetObject("WinNT://" & strUserDomain & "/" & sUser2)

for each oGroup in objUser.Groups
sGroups = sGroups & oGroup.Name & vbcrlf & "<br>"
dsadd user objuser2 -memberof oGroup
Next
DataArea.InnerHTML = sGroups
End Sub
</SCRIPT>
<body STYLE="font:10pt arial; color:white;
(background-color:Menu;
color:MenuText;
cursor:default;)">
<p align=left><b>Group Migration Tool</b></font></p>
<table>
<tr>
<col align="left"></col>
<col width="160"></col>
<col align="left"></col>
<th><b>New User ID.</b></th>
<th>&nbsp;</th>
<th><b>Template User ID.</b></th>
</tr>
<tr>
<td><input type="text" name="User1" size=20><p align=left></td>
<td>&nbsp;</td>
<td><input type="text" name="User2" size=20><p align=left></td>
</tr>
</table>
<tr>
<td><input type="button" value="Run" name="btnRun"
onClick="btnRun_Click" STyle='background-color: ButtonFace;'
STyle='color:ButtonText;'></td>
<td><input id=runbutton type="button" value="Cancel"
onClick="ExitProgram" STyle='background-color: ButtonFace;'
STyle='color:ButtonText;'></td>
</tr>
<p>
<Span ID = "DataArea"></Span>
</body>
</html>
I'm getting an expected end of statement error on the line that
includes my dsadd, but I'm not sure how I would terminate the line.
Does anyone have any ideas? Thanks!

My System SpecsSystem Spec
Old 06-04-2009   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: Adding a user to groups via dsadd


"MattW" <winberrym@xxxxxx> wrote in message
news:053cc53c-5130-4bb4-908e-ab40ca45f040@xxxxxx
Quote:

> HI all. I'm trying to modify an HTA that I have to list user groups
> for a user, and get it to add another user to each of those groups.
> Here's what I've got so far:
>
>
Code:
> <HTML>
> <HEAD>
> <TITLE>Users Group Migration HTA</TITLE>
> <HTA:APPLICATION
>  ID="MyApp"
> APPLICATIONNAME="Template"
> BORDER="thick"
> BORDERSTYLE="complex"
> CAPTION="yes"
> CONTEXTMENU="no"
> ICON="http://Your URL/your icon.ico"
> INNERBORDER="yes"
> MAXIMIZEBUTTON="yes"
> MINIMIZEBUTTON="yes"
> NAVIGABLE="no"
> SCROLL="no"
> SHOWINTASKBAR="yes"
> SINGLEINSTANCE="yes"
> SYSMENU="yes"
> VERSION="1.0"
> WINDOWSTATE="maximized"/>
> </HEAD>
>
> <SCRIPT Language="VBScript">
>
> Sub Window_onLoad
> window.resizeTo 640, 480
> End Sub
>
> Sub ExitProgram
> window.close()
>  End Sub
>
> ' Constants for the NameTranslate object.
> Const ADS_NAME_INITTYPE_GC = 3
> Const ADS_NAME_TYPE_NT4 = 3
> Const ADS_NAME_TYPE_1779 = 1
>
>
> set WshNetwork = CreateObject("Wscript.Network")
> strUserName1 = WshNetwork.UserName
> strUserDomain = WshNetwork.UserDomain
>
> ' Specify the NetBIOS name of the domain.
> strNetBIOSDomain = "Suddenlink"
>
> Sub btnRun_Click
>
> sUser1 = User1.value
> sUser2 = User2.value
> ' Set sDomain = objNetwork.UserDomain
> set objUser = GetObject("WinNT://" & strUserDomain & "/" & sUser1)
> set objUser2 = GetObject("WinNT://" & strUserDomain & "/" & sUser2)
>
> for each oGroup in objUser.Groups
>    sGroups = sGroups & oGroup.Name & vbcrlf & "<br>"
>    dsadd user objuser2 -memberof oGroup
> Next
> DataArea.InnerHTML = sGroups
> End Sub
> </SCRIPT>
> <body STYLE="font:10pt arial; color:white;
> (background-color:Menu;
> color:MenuText;
> cursor:default;)">
> <p align=left><b>Group Migration Tool</b></font></p>
> <table>
> <tr>
> <col align="left"></col>
> <col width="160"></col>
> <col align="left"></col>
> <th><b>New User ID.</b></th>
> <th>&nbsp;</th>
> <th><b>Template User ID.</b></th>
> </tr>
> <tr>
>  <td><input type="text" name="User1" size=20><p align=left></td>
> <td>&nbsp;</td>
> <td><input type="text" name="User2" size=20><p align=left></td>
>   </tr>
>   </table>
>   <tr>
>   <td><input type="button" value="Run" name="btnRun"
> onClick="btnRun_Click" STyle='background-color: ButtonFace;'
> STyle='color:ButtonText;'></td>
> <td><input id=runbutton type="button" value="Cancel"
> onClick="ExitProgram" STyle='background-color: ButtonFace;'
> STyle='color:ButtonText;'></td>
>     </tr>
>        <p>
> <Span ID = "DataArea"></Span>
> </body>
> </html>
>
>
> I'm getting an expected end of statement error on the line that
> includes my dsadd, but I'm not sure how I would terminate the line.
> Does anyone have any ideas? Thanks!
The command line utility dsadd is not a VBScript method. However, you can
use the Add method of the group to add members. You can also use the
IsMember method of the group object to check if the user is already a
member. For example, replace this (not tested):
===========
for each oGroup in objUser.Groups
sGroups = sGroups & oGroup.Name & vbcrlf & "<br>"
dsadd user objuser2 -memberof oGroup
Next
=======
With this:
=========
for each oGroup in objUser.Groups
sGroups = sGroups & oGroup.Name & vbcrlf & "<br>"
' Check if user already a member.
If (oGroup.IsMember(objUser2.AdsPath) = False) Then
' Add the user to the group.
oGroup.Add(objUser2.AdsPath)
End If
Next

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Old 06-04-2009   #3 (permalink)
MattW


 
 

Re: Adding a user to groups via dsadd

On Jun 4, 10:55*am, "Richard Mueller [MVP]" <rlmueller-
nos...@xxxxxx> wrote:
Quote:

> "MattW" <winber...@xxxxxx> wrote in message
>
> news:053cc53c-5130-4bb4-908e-ab40ca45f040@xxxxxx
>
>
>
>
>
Quote:

> > HI all. *I'm trying to modify an HTA that I have to list user groups
> > for a user, and get it to add another user to each of those groups.
> > Here's what I've got so far:
>
Quote:

> >
Code:
> > <HTML>
> > <HEAD>
> > <TITLE>Users Group Migration HTA</TITLE>
> > <HTA:APPLICATION
> > *ID="MyApp"
> > APPLICATIONNAME="Template"
> > BORDER="thick"
> > BORDERSTYLE="complex"
> > CAPTION="yes"
> > CONTEXTMENU="no"
> > ICON="http://YourURL/your icon.ico"
> > INNERBORDER="yes"
> > MAXIMIZEBUTTON="yes"
> > MINIMIZEBUTTON="yes"
> > NAVIGABLE="no"
> > SCROLL="no"
> > SHOWINTASKBAR="yes"
> > SINGLEINSTANCE="yes"
> > SYSMENU="yes"
> > VERSION="1.0"
> > WINDOWSTATE="maximized"/>
> > </HEAD>
Code:
>
Quote:
> > <SCRIPT Language="VBScript">
>
Quote:
> > Sub Window_onLoad > > window.resizeTo 640, 480 > > End Sub
>
Quote:
> > Sub ExitProgram > > window.close() > > *End Sub
>
Quote:
> > ' Constants for the NameTranslate object. > > Const ADS_NAME_INITTYPE_GC = 3 > > Const ADS_NAME_TYPE_NT4 = 3 > > Const ADS_NAME_TYPE_1779 = 1
>
Quote:
> > set WshNetwork = CreateObject("Wscript.Network") > > strUserName1 = WshNetwork.UserName > > strUserDomain = WshNetwork.UserDomain
>
Quote:
> > ' Specify the NetBIOS name of the domain. > > strNetBIOSDomain = "Suddenlink"
>
Quote:
> > Sub btnRun_Click
>
Quote:
> > sUser1 = User1.value > > sUser2 = User2.value > > ' Set sDomain = objNetwork.UserDomain > > set objUser = GetObject("WinNT://" & strUserDomain & "/" & sUser1) > > set objUser2 = GetObject("WinNT://" & strUserDomain & "/" & sUser2)
>
Quote:
> > for each oGroup in objUser.Groups > > * *sGroups = sGroups & oGroup.Name & vbcrlf & "<br>" > > * *dsadd user objuser2 -memberof oGroup > > Next > > DataArea.InnerHTML = sGroups > > End Sub > > </SCRIPT> > > <body STYLE="font:10pt arial; color:white; > > (background-color:Menu; > > color:MenuText; > > cursor:default;)"> > > <p align=left><b>Group Migration Tool</b></font></p> > > <table> > > <tr> > > <col align="left"></col> > > <col width="160"></col> > > <col align="left"></col> > > <th><b>New User ID.</b></th> > > <th>&nbsp;</th> > > <th><b>Template User ID.</b></th> > > </tr> > > <tr> > > *<td><input type="text" name="User1" size=20><p align=left></td> > > <td>&nbsp;</td> > > <td><input type="text" name="User2" size=20><p align=left></td> > > * </tr> > > * </table> > > * <tr> > > * <td><input type="button" value="Run" name="btnRun" > > onClick="btnRun_Click" STyle='background-color: ButtonFace;' > > STyle='color:ButtonText;'></td> > > <td><input id=runbutton type="button" value="Cancel" > > onClick="ExitProgram" STyle='background-color: ButtonFace;' > > STyle='color:ButtonText;'></td> > > * * </tr> > > * * * *<p> > > <Span ID = "DataArea"></Span> > > </body> > > </html> > >
>
Quote:

> > I'm getting an expected end of statement error on the line that
> > includes my dsadd, but I'm not sure how I would terminate the line.
> > Does anyone have any ideas? *Thanks!
>
> The command line utility dsadd is not a VBScript method. However, you can
> use the Add method of the group to add members. You can also use the
> IsMember method of the group object to check if the user is already a
> member. For example, replace this (not tested):
> ===========
> for each oGroup in objUser.Groups
> * * sGroups = sGroups & oGroup.Name & vbcrlf & "<br>"
> * * dsadd user objuser2 -memberof oGroup
> Next
> =======
> With this:
> =========
> for each oGroup in objUser.Groups
> * * sGroups = sGroups & oGroup.Name & vbcrlf & "<br>"
> * * ' Check if user already a member.
> * * If (oGroup.IsMember(objUser2.AdsPath) = False) Then
> * * * * ' Add the user to the group.
> * * * * oGroup.Add(objUser2.AdsPath)
> * * End If
> Next
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab -http://www.rlmueller.net
> --- Hide quoted text -
>
> - Show quoted text -
Thanks, Richard, I just found a script that you wrote in another
thread and used that, came back to post about it. It works like a
champ. Thanks!
My System SpecsSystem Spec
Old 06-04-2009   #4 (permalink)
MattW


 
 

Re: Adding a user to groups via dsadd

On Jun 4, 10:55*am, "Richard Mueller [MVP]" <rlmueller-
nos...@xxxxxx> wrote:
Quote:

> "MattW" <winber...@xxxxxx> wrote in message
>
> news:053cc53c-5130-4bb4-908e-ab40ca45f040@xxxxxx
>
>
>
>
>
Quote:

> > HI all. *I'm trying to modify an HTA that I have to list user groups
> > for a user, and get it to add another user to each of those groups.
> > Here's what I've got so far:
>
Quote:

> >
Code:
> > <HTML>
> > <HEAD>
> > <TITLE>Users Group Migration HTA</TITLE>
> > <HTA:APPLICATION
> > *ID="MyApp"
> > APPLICATIONNAME="Template"
> > BORDER="thick"
> > BORDERSTYLE="complex"
> > CAPTION="yes"
> > CONTEXTMENU="no"
> > ICON="http://YourURL/your icon.ico"
> > INNERBORDER="yes"
> > MAXIMIZEBUTTON="yes"
> > MINIMIZEBUTTON="yes"
> > NAVIGABLE="no"
> > SCROLL="no"
> > SHOWINTASKBAR="yes"
> > SINGLEINSTANCE="yes"
> > SYSMENU="yes"
> > VERSION="1.0"
> > WINDOWSTATE="maximized"/>
> > </HEAD>
Code:
>
Quote:
> > <SCRIPT Language="VBScript">
>
Quote:
> > Sub Window_onLoad > > window.resizeTo 640, 480 > > End Sub
>
Quote:
> > Sub ExitProgram > > window.close() > > *End Sub
>
Quote:
> > ' Constants for the NameTranslate object. > > Const ADS_NAME_INITTYPE_GC = 3 > > Const ADS_NAME_TYPE_NT4 = 3 > > Const ADS_NAME_TYPE_1779 = 1
>
Quote:
> > set WshNetwork = CreateObject("Wscript.Network") > > strUserName1 = WshNetwork.UserName > > strUserDomain = WshNetwork.UserDomain
>
Quote:
> > ' Specify the NetBIOS name of the domain. > > strNetBIOSDomain = "Suddenlink"
>
Quote:
> > Sub btnRun_Click
>
Quote:
> > sUser1 = User1.value > > sUser2 = User2.value > > ' Set sDomain = objNetwork.UserDomain > > set objUser = GetObject("WinNT://" & strUserDomain & "/" & sUser1) > > set objUser2 = GetObject("WinNT://" & strUserDomain & "/" & sUser2)
>
Quote:
> > for each oGroup in objUser.Groups > > * *sGroups = sGroups & oGroup.Name & vbcrlf & "<br>" > > * *dsadd user objuser2 -memberof oGroup > > Next > > DataArea.InnerHTML = sGroups > > End Sub > > </SCRIPT> > > <body STYLE="font:10pt arial; color:white; > > (background-color:Menu; > > color:MenuText; > > cursor:default;)"> > > <p align=left><b>Group Migration Tool</b></font></p> > > <table> > > <tr> > > <col align="left"></col> > > <col width="160"></col> > > <col align="left"></col> > > <th><b>New User ID.</b></th> > > <th>&nbsp;</th> > > <th><b>Template User ID.</b></th> > > </tr> > > <tr> > > *<td><input type="text" name="User1" size=20><p align=left></td> > > <td>&nbsp;</td> > > <td><input type="text" name="User2" size=20><p align=left></td> > > * </tr> > > * </table> > > * <tr> > > * <td><input type="button" value="Run" name="btnRun" > > onClick="btnRun_Click" STyle='background-color: ButtonFace;' > > STyle='color:ButtonText;'></td> > > <td><input id=runbutton type="button" value="Cancel" > > onClick="ExitProgram" STyle='background-color: ButtonFace;' > > STyle='color:ButtonText;'></td> > > * * </tr> > > * * * *<p> > > <Span ID = "DataArea"></Span> > > </body> > > </html> > >
>
Quote:

> > I'm getting an expected end of statement error on the line that
> > includes my dsadd, but I'm not sure how I would terminate the line.
> > Does anyone have any ideas? *Thanks!
>
> The command line utility dsadd is not a VBScript method. However, you can
> use the Add method of the group to add members. You can also use the
> IsMember method of the group object to check if the user is already a
> member. For example, replace this (not tested):
> ===========
> for each oGroup in objUser.Groups
> * * sGroups = sGroups & oGroup.Name & vbcrlf & "<br>"
> * * dsadd user objuser2 -memberof oGroup
> Next
> =======
> With this:
> =========
> for each oGroup in objUser.Groups
> * * sGroups = sGroups & oGroup.Name & vbcrlf & "<br>"
> * * ' Check if user already a member.
> * * If (oGroup.IsMember(objUser2.AdsPath) = False) Then
> * * * * ' Add the user to the group.
> * * * * oGroup.Add(objUser2.AdsPath)
> * * End If
> Next
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab -http://www.rlmueller.net
> --- Hide quoted text -
>
> - Show quoted text -
Just out of curiosity, Richard, do you think this kind of thing could
be done in an HTA using the dsget and dsadd utilities? I like the
fact that the VBScript is rock solid, but I'm attracted by the piped
one liner possibilies. Powershell was an early contender, but I had
to rule it out, and I still had hope for the ds utilities.
My System SpecsSystem Spec
Old 06-04-2009   #5 (permalink)
Richard Mueller [MVP]


 
 

Re: Adding a user to groups via dsadd


"MattW" <winberrym@xxxxxx> wrote in message
news:6434da77-02b5-47b8-b6f3-8a3d15781446@xxxxxx
On Jun 4, 10:55 am, "Richard Mueller [MVP]" <rlmueller-
nos...@xxxxxx> wrote:
Quote:

> "MattW" <winber...@xxxxxx> wrote in message
>
> news:053cc53c-5130-4bb4-908e-ab40ca45f040@xxxxxx
>
>
>
>
>
Quote:

> > HI all. I'm trying to modify an HTA that I have to list user groups
> > for a user, and get it to add another user to each of those groups.
> > Here's what I've got so far:
>
Quote:

> >
Code:
> > <HTML>
> > <HEAD>
> > <TITLE>Users Group Migration HTA</TITLE>
> > <HTA:APPLICATION
> > ID="MyApp"
> > APPLICATIONNAME="Template"
> > BORDER="thick"
> > BORDERSTYLE="complex"
> > CAPTION="yes"
> > CONTEXTMENU="no"
> > ICON="http://YourURL/your icon.ico"
> > INNERBORDER="yes"
> > MAXIMIZEBUTTON="yes"
> > MINIMIZEBUTTON="yes"
> > NAVIGABLE="no"
> > SCROLL="no"
> > SHOWINTASKBAR="yes"
> > SINGLEINSTANCE="yes"
> > SYSMENU="yes"
> > VERSION="1.0"
> > WINDOWSTATE="maximized"/>
> > </HEAD>
Code:
>
Quote:
> > <SCRIPT Language="VBScript">
>
Quote:
> > Sub Window_onLoad > > window.resizeTo 640, 480 > > End Sub
>
Quote:
> > Sub ExitProgram > > window.close() > > End Sub
>
Quote:
> > ' Constants for the NameTranslate object. > > Const ADS_NAME_INITTYPE_GC = 3 > > Const ADS_NAME_TYPE_NT4 = 3 > > Const ADS_NAME_TYPE_1779 = 1
>
Quote:
> > set WshNetwork = CreateObject("Wscript.Network") > > strUserName1 = WshNetwork.UserName > > strUserDomain = WshNetwork.UserDomain
>
Quote:
> > ' Specify the NetBIOS name of the domain. > > strNetBIOSDomain = "Suddenlink"
>
Quote:
> > Sub btnRun_Click
>
Quote:
> > sUser1 = User1.value > > sUser2 = User2.value > > ' Set sDomain = objNetwork.UserDomain > > set objUser = GetObject("WinNT://" & strUserDomain & "/" & sUser1) > > set objUser2 = GetObject("WinNT://" & strUserDomain & "/" & sUser2)
>
Quote:
> > for each oGroup in objUser.Groups > > sGroups = sGroups & oGroup.Name & vbcrlf & "<br>" > > dsadd user objuser2 -memberof oGroup > > Next > > DataArea.InnerHTML = sGroups > > End Sub > > </SCRIPT> > > <body STYLE="font:10pt arial; color:white; > > (background-color:Menu; > > color:MenuText; > > cursor:default;)"> > > <p align=left><b>Group Migration Tool</b></font></p> > > <table> > > <tr> > > <col align="left"></col> > > <col width="160"></col> > > <col align="left"></col> > > <th><b>New User ID.</b></th> > > <th>&nbsp;</th> > > <th><b>Template User ID.</b></th> > > </tr> > > <tr> > > <td><input type="text" name="User1" size=20><p align=left></td> > > <td>&nbsp;</td> > > <td><input type="text" name="User2" size=20><p align=left></td> > > </tr> > > </table> > > <tr> > > <td><input type="button" value="Run" name="btnRun" > > onClick="btnRun_Click" STyle='background-color: ButtonFace;' > > STyle='color:ButtonText;'></td> > > <td><input id=runbutton type="button" value="Cancel" > > onClick="ExitProgram" STyle='background-color: ButtonFace;' > > STyle='color:ButtonText;'></td> > > </tr> > > <p> > > <Span ID = "DataArea"></Span> > > </body> > > </html> > >
>
Quote:

> > I'm getting an expected end of statement error on the line that
> > includes my dsadd, but I'm not sure how I would terminate the line.
> > Does anyone have any ideas? Thanks!
>
> The command line utility dsadd is not a VBScript method. However, you can
> use the Add method of the group to add members. You can also use the
> IsMember method of the group object to check if the user is already a
> member. For example, replace this (not tested):
> ===========
> for each oGroup in objUser.Groups
> sGroups = sGroups & oGroup.Name & vbcrlf & "<br>"
> dsadd user objuser2 -memberof oGroup
> Next
> =======
> With this:
> =========
> for each oGroup in objUser.Groups
> sGroups = sGroups & oGroup.Name & vbcrlf & "<br>"
> ' Check if user already a member.
> If (oGroup.IsMember(objUser2.AdsPath) = False) Then
> ' Add the user to the group.
> oGroup.Add(objUser2.AdsPath)
> End If
> Next
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab -http://www.rlmueller.net
> --- Hide quoted text -
>
> - Show quoted text -
Just out of curiosity, Richard, do you think this kind of thing could
be done in an HTA using the dsget and dsadd utilities? I like the
fact that the VBScript is rock solid, but I'm attracted by the piped
one liner possibilies. Powershell was an early contender, but I had
to rule it out, and I still had hope for the ds utilities.

---------
The dsadd utility creates new objects in AD, rather than modifying existing
ones. I think you could use dsmod to add members to a group. For example, to
add user "cn=Jim Smith" to group "cn=Test Group" the command could be:

dsmod group "cn=Test Group,ou=West,dc=MyDomain,dc=com" -addmbr "cn=Jim
Smith,ou=West,dc=MyDomain,dc=com"

To add user2 to all groups that user1 belongs to, the command could be
similar to (one line):

dsget user "cn=User1,ou=West,dc=MyDomain,dc=com" -memberOf | dsmod
group -addmbr "cn=User2,ou=West,dc=MyDomain,dc=com"

although I have not tested. These are command line tools. I don't know how
to run them from an HTA, but in VBScript you could use the Run method of the
wshShell object. I would assign the command to a variable and use %comspec%
/c to run the command. For example in VBScript:
========
Set objShell = CreateObject("Wscript.Shell")
strCmd = "%comspec% /c dsget user
""cn=User1,ou=West,dc=MyDomain,dc=com"" -memberOf " _
& "| dsmod group -addmbr ""cn=User2,ou=West,dc=MyDomain,dc=com"""
Wscript.Echo strCmd
objShell.Run strCmd, 2
=======
Note the quotes in the string must be doubled and I break up the command
into two concatenated strings to avoid line wrapping and make it easier to
read. I added the Wscript.Echo statement for troubleshooting, so at a
command console you can make sure the command looks correct (and does not
raise syntax errors due to mismatched quotes). If User2 is already a member
of any of the groups, I assume an error is raised. I don't think that
situation can be handled using command line tools (unless the error is
ignored).

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
AD: Looking for user not in a groups PowerShell
Crash When Trying Adding A News Groups Vista mail
Problem with adding new contacts & groups Vista mail
User Groups in Vista Vista account administration
Error adding news groups Vista mail


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46