Geeks With Blogs
Chris' Weblog

Here is a quick Vbscript that can be used to create roles in ADAM. I suppose you can also use Ldifde but, I get lazy formatting the .LDF file, etc. So here is what this script does:

  1. It calls the input file specified when executing the script. (e.g. cscript CreateADAMRoles.vbs )
  1. It reads the input file, and begins the loop line by line until the end of the file. During each loop, it performs the following ADSI routines.
  1. Connects to LDAP defined within the Global Settings. (e.g. LDAP://localhost:389/cn=roles,dc=contoso,dc=com)
  1. Create a group object, naming it the value defined within the line read. (e.g. cn=Role1). It also sets the groupType value which is a required attribute to be successful.
  1. Upon completion, loop again.

A downloadable version can be obtained here.

Option Explicit

Dim objFSO,objFile, objOU, objGroup, objArgs
Dim strLine, sDomainDN, sInputFile


'GLOBAL SETTINGS - Please set these values as per your environment
sDomainDN = "localhost:389/cn=roles,dc=contoso,dc=com"

Set objArgs = WScript.Arguments

If Wscript.Arguments.Count = 0 Then
WScript.Echo ("No input file given on command line." & VbCrLf &_
" Usage: [cscript|wscript] " & WScript.ScriptName & " ")

End If

sInputFile = objArgs(0)

Set objFSO = CreateObject ("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile (sInputFile, 1)

Do Until objFile.AtEndOfStream
strLine = objFile.Readline

Set objOU = GetObject("LDAP://" & sDomainDN)
Set objGroup = objOU.Create("Group", "CN=" & strLine)

WScript.Echo "Creating Group: " & strLine
objGroup.Put "groupType", "-2147483646"



Posted on Wednesday, May 31, 2006 10:01 PM | Back to top

Comments on this post: Create Group Objects (Roles) in ADAM

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Chris Calderon | Powered by: