Welcome to WiseSoft.co.uk!
Register
About
Contact
Donate
Home
Scripts
Articles
Software
Forum
Links
Active Directory Schema Guide
Submit a Script
All Scripts
Active Directory
Computer
Database
Event Logs
Exchange/Email
File System
General
Printer
SQL Server
Account Page
Address Page
COMPlus Page
DialIn Page
Environment Page
General Page
MemberOf Page
Organization Page
Profile Page
RemoteControl Page
Sessions Page
Telephones Page
TerminalServices Page
Batch File
HTA
KiXtart
PowerShell
T-SQL
VB
VBScript
Computer Accounts
Domains, Forests & Trusts
Groups
Monitoring & Replication
Organizational Units
Schema Information
Search
Sites and Subnets
User Accounts
PowerShell
VBScript
VBScript
PowerShell
VBScript
VBScript
VBScript
VBScript
VBScript
PowerShell
VBScript
VBScript
PowerShell
VBScript
HTA
KiXtart
PowerShell
VB
VBScript
VBScript
KiXtart
PowerShell
VBScript
PowerShell
VBScript
Batch File
KiXtart
PowerShell
VBScript
HTA
VB
VBScript
HTA
KiXtart
PowerShell
VBScript
HTA
PowerShell
T-SQL
VBScript
All Articles
Active Directory
Miscellaneous
Programming
Scripting
Security
SQL Server
WiseSoft
Submit Article
All Software
TSQL DDL Code History Tool
Account Management Spreadsheet
Bulk AD Users
Password Control
Script Builder
NTFSFix
TSQL DDL Code History Tool
Bulk AD Users
Password Control
Script Builder
Account Management Spreadsheet
NTFSFix
Scripting
Guestbook
Bugs
Suggestions
General
Bugs
Suggestions
General
Bugs
Suggestions
General
Bugs
Suggestions
General
Bugs
Suggestions
General
Bugs
Suggestions
General
Login
User Name:
Password:
Remember me next time
Forgot Password?
Login using OpenID:
Create free account
Exclusive access for registered users
Registered Users:
20870
Click here to find out how you can help support wisesoft.co.uk!
home
recent topics
recent posts
search
faq
AspNetForum v.5.2.7.0
WiseSoft :: Forum
:: Forum
user:
psw:
remember me
|
lost password
|
register
Home
»
Scripting
»
User creation script - Adding to groups
|
12/30/2011 4:52:55 AM
permalink
ADixon
Posts 2
I've written a script for AD user creation and am having issues when adding to security groups. Here is a snippet:
Function SetSecGroups()
Dim objOption
For Each objOption In SecGroups.Options
If objoption.selected then
GroupPath = objoption.value
UserPath = ("LDAP://" & strDistName)
addToGroup UserPath,GroupPath
Else
End If
Next
End function
Sub addToGroup(UserPath, GroupPath)
Dim objGroup
Set objGroup = GetObject(GroupPath)
For Each member In objGroup.members
If LCase(member.adspath) = LCase(userPath) Then
Exit Sub
End If
Next
objGroup.Add(UserPath)
End Sub
The whole script is a HTA which creates the user and set's all of the necessary attributes, this bit works fine but when trying to add to groups it fails. The groups are in a dropdown in the HTA so i use SecGroups.options to find the selected groups. The variables are passed to the addToGroup sub and it cycles through the existing members to ensure the new user isn't already a member. I use HTAEdit so can debug to an extent but i can't see why the new user isn't added. Can anyone shed any light on why this may be? Thanks in advance, AD
1/13/2012 1:39:49 PM
permalink
admin
Posts 331
Hi,
What part of the script is failing and what error do you get? Have you checked the group path is the full ADsPath - not just the distinguished name? Does the bind to the group work and have you tried to bind to the userPath to ensure that is also correct. Here's a simpler example with less moving parts than your HTA if you want to try:
http://www.wisesoft.co.uk/scripts/vbscript_add_user_to_group.aspx
Hope this helps,
David
1/15/2012 1:18:00 PM
permalink
ADixon
Posts 2
Thanks for the reply David.
This snippet works when used as a standalone vbs script to add a group to an existing user. I've found that (by using messageboxes) i am getting the correct ADS path. Also, adding a pause in the main HTA allows the user to be seen on the DC i use, otherwise it can't find the strDistName, even though i've used specific DC's for both adding the user and adding to groups. So the script is failing on the objGroup.Add right at the end.
Thanks for the example btw, i'll give that a go.
Many thanks for the help
pages:
1
|
Home
»
Scripting
»
User creation script - Adding to groups