Creating Windows accounts is never fun when doing it via a user manager GUI. It is obviously mundane and slow. Especially when you may need to add multiple amounts of users at a time.
What needs to happen in this case is to read in each user_id and the account parameters, then go ahead and create them in a batch process. At our organisation we use a text file to replicate the accounts to a Novell system from a Windows domain controller via a simple comma ',' delimited text file using DirXML. Now that part of the process is not what I seek answers for. But what I do seek answers for is the interfacing of Perl to Windows user accounts.
So I have the obvious choice of Windows Script, which takes for ever to read in user account Objects and is quite frankly not really how I want to approach this because of speed and functionality. Batch files are also out of the question I think. And the user manager apps are just out of the question...
I want to use Perl because I know it can do everything and , does the job efficiently, gives a good array of functionality and is a joy to work with.
I am probably going to use
Win32API::Net within a
TK interface that prompts for all required/possible account paramaters from one main Window.
Just fishing for ideas :)
Here is a wacky Windows Script which I just knocked up which adds one user at a time. Im really just looking for an example or two of some interfacing from Perl to Windows accounts.
Here comes the Wscript :P (/me cannot believe he is posting a Windows Script on a Perl board ...)
<job id="add_user">
<script language=vbscript>
' Script name : addusers.wsf
' Description : A lame example of user creation using Wscript
msgbox("This script will create the username under the windows domain
+'"&domain&"' with the information you specify. " _
& VbCrLf & "Please wait while I build a list of user objects on th
+e domain/computer ...")
domain = "some_windows_domain"
Set domainObj = GetObject("WinNT://"&domain)
add_users = 1
Do While add_users = 1
Dim domain
Dim user_exists_check
Dim user_id
Dim user_fullname
Dim user_location
Dim user_password
Dim add_users
user_id=inputbox("Username:","Enter the userid/username")
user_fullname=inputbox("Full Name of user:","Enter the user's full
+ name")
user_location=inputbox("User's location:","Branch/Location of user
+")
user_password=inputbox("Password:","Enter user's password")
If user_id = "" or user_fullname = "" or user_location = "" or use
+r_password = "" Then
msgbox("NULL user paramater specified. Please make sure you en
+ter a value for each paramater!")
Else
ListUsers
If user_exists_check = "EXISTS" Then
msgbox("User '"&user_id&"' already exists ... USER NOT ADD
+ED")
user_exists_check = ""
Else
Add_user
End If
End If
keep_adding=msgbox("Add another user ?",VbOkCancel)
If keep_adding <> 1 Then
add_users = 0
End If
Loop
Sub ListUsers
domainObj.Filter = Array( "User" )
For Each objUser In domainObj
existingUser=objUser.Name
If existingUser = user_id Then
user_exists_check="EXISTS"
Exit Sub
End If
Next
End Sub
Sub Add_user
Set oUser = domainObj.Create ("user", user_id)
oUser.SetInfo
oUser.Fullname = user_fullname
oUser.SetPassword user_password
oUser.Description = user_location & " blah blah user"
oUser.AccountDisabled = False
oUser.IsAccountLocked = False
oUser.SetInfo
ListUsers
If user_exists_check = "EXISTS" Then
msgbox("Added user '"&user_id&"' ...OK")
Else
msgbox("User not added!")
End If
End Sub
</script>
</job>
Show us your code ;)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.