For detailed info, check out the keyword "ADSI" on
http://msdn.microsoft.com
This was copied out of a program I wrote a few years ago to create user
accounts for students and staff for Bloomington schools. If anyone is
interested in the entire program, I can zip it up and e-mail it
individually.
Note that this program (and hence, the attached sample code) was written
before I started with Microsoft, and MS is not responsible for any
damage it may cause your systems! Use at your own risk!
Hope this helps!
Sincerely,
Brian E. Adams, MCSE+I, MCSD, MCDBA, CCNA
Microsoft Corporation
Central Region Financial Services Group - MCS
Pocket PC and Embedded Windows Champ
Voice: 309-287-3094 / E-Mail: [EMAIL PROTECTED]
-----Original Message-----
From: griffin [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 17, 2001 9:13 AM
To: [EMAIL PROTECTED]
Subject: RE: [Techgeeks] Command Line Add User
Here's some batch files I use. .cmd is the same as .bat to NT. Some of
these make users some make groups and one puts users into groups. The
net user command can also remove these things too. Actually, it seems
to get over looked a lot but the command line stuff in NT is
exceptional. Many commands that have been around a long time are much
improved in NT. For example, the FOR command can parse files and
directories and has much extra functionality compared to what was with
MSDOS or with 9x.
>>> [EMAIL PROTECTED] 07/17/01 09:04AM >>>
We want both of them. We're gluttons for punishment, uh.. I mean
productivity.
Travis.
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of griffin
Sent: Tuesday, July 17, 2001 8:58 AM
To: [EMAIL PROTECTED]
Subject: Re: [Techgeeks] Command Line Add User
Are you wanting a script from Brian or a batch file?
>>> [EMAIL PROTECTED] 07/17/01 08:42AM >>>
I would like to see one.
----- Original Message -----
From: "Brian Adams (MCS)" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 16, 2001 10:42 PM
Subject: RE: [Techgeeks] Command Line Add User
> This can also be scripted very easily in VB Script if NET USER doesn't
> provide all that you require. I can write up a sample script if
> anyone's interested.
>
>
>
> Sincerely,
> Brian E. Adams, MCSE+I, MCSD, MCDBA, CCNA
> Microsoft Corporation
> Central Region Financial Services Group - MCS
> Pocket PC and Embedded Windows Champ
> Voice: 309-287-3094 / E-Mail: [EMAIL PROTECTED]
>
>
>
>
> -----Original Message-----
> From: griffin [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 16, 2001 4:16 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [Techgeeks] Command Line Add User
>
> The net user command has the ability to create user accounts at the
> command line. That's how I quicky create user accounts with a batch
> file for tech class use. I can get you the exact syntax if you want
it.
>
> Don Griffin
> Regional Office of Education 13
> MCNE, MCNI, CCNA, MCSE (NT & 2K!), MCT
>
> >>> [EMAIL PROTECTED] 07/16/01 03:26PM >>>
> Is there a way to add users to an NT Domain and create an exchange
> mailbox
> from a command line? I want to create an external application that
will
> allow our database to add users and remove users from our NT domain.
>
> Thanks for your help!
>
> Adam Vocks
> Taylorville CUSD #3
>
>
> To unsubscribe, send a message to [EMAIL PROTECTED] with
> unsubscribe techgeeks
> as the BODY of the message. The SUBJECT is ignored.
>
>
>
> To unsubscribe, send a message to [EMAIL PROTECTED] with
> unsubscribe techgeeks
> as the BODY of the message. The SUBJECT is ignored.
>
>
> To unsubscribe, send a message to [EMAIL PROTECTED] with
> unsubscribe techgeeks
> as the BODY of the message. The SUBJECT is ignored.
>
To unsubscribe, send a message to [EMAIL PROTECTED] with
unsubscribe techgeeks
as the BODY of the message. The SUBJECT is ignored.
To unsubscribe, send a message to [EMAIL PROTECTED] with
unsubscribe techgeeks
as the BODY of the message. The SUBJECT is ignored.
To unsubscribe, send a message to [EMAIL PROTECTED] with
unsubscribe techgeeks
as the BODY of the message. The SUBJECT is ignored.
' Create User Account
Set objDomain = GetObject("WinNT://" & strNTDomain)
Set objUser = objDomain.Create("user", strUserName)
objUser.FullName = strFullName
Select Case blnStaffMember
Case False
objUser.Description = "Student"
Case True
objUser.Description = "Staff"
End Select
objUser.SetInfo 'must commit creation of user account before any other
attributes can be set
'Set User's Password
Select Case strPassword
Case ""
'leave password as blank
Case Else
objUser.SetPassword (strPassword)
objUser.SetInfo
End Select
objUser.SetInfo
'Create User's Home and Profile Directories
'create user's home directory and set the appropriate attribute on the
user account
fso.CreateFolder "\\" & strServerName & "\Users\" & strUserName
objUser.HomeDirectory = "\\" & strServerName & "\Users\" & strUserName
objUser.SetInfo
'create user's profile directory (within the home directory) and set the
appropriate attribute on the user account
fso.CreateFolder "\\" & strServerName & "\Users\" & strUserName &
"\Profile"
objUser.Profile = "\\" & strServerName & "\Users\" & strUserName &
"\Profile"
objUser.SetInfo
'ensure permissions are correct on home directory and that user owns their
own home directory
'this process requires a proprietary tool available from
http://www.trustedsystems.com - SuperCACLS
Dim strACLModification As String
strACLModification = "reacl /a " & strUserName & ":fullcontrol
administrators:fullcontrol /o " & strUserName & _
" /priv /s /t \\" & strServerName & "\users\" & strUserName
Shell strACLModification, vbMinimizedNoFocus
pbCurrentStudent.Value = 35
' Add User to Proper Group
Select Case blnStaffMember
Case False
Set objGroup = objDomain.GetObject("Group", strStudentGroupName)
objGroup.Add ("WinNT://" & strNTDomain & "/" & strUserName)
Case True
Set objGroup = objDomain.GetObject("Group", strStaffGroupName)
objGroup.Add ("WinNT://" & strNTDomain & "/" & strUserName)
'Check whether we should add the user to the domain admins group for the
domain
If blnMakeDomainAdministrator = True Then
Set objGroup = objDomain.GetObject("Group", "Domain Admins")
objGroup.Add ("WinNT://" & strNTDomain & "/" & strUserName)
End If
Else
'no not add user to any groups
End If
' Set Other Account Properties
objUser.LoginScript = strLogonScript
objUser.SetInfo
'Clean Up
Set objDomain = Nothing
Set objUser = Nothing
Set objGroup = Nothing
Set objLogFile = Nothing