0% found this document useful (0 votes)
48 views1 page

Option Explicit DIM DIM DIM

This document contains a VBScript that uses ADSI to create a new user in an Active Directory domain. It sets variables for the domain name, user name, full name, description, and password. It then uses the GetObject and Create methods to get a reference to the domain object and create a new user object, setting the Description and FullName properties before storing the new user information. It displays a success or error message depending on if the user was successfully created or if an error occurred.

Uploaded by

radutari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views1 page

Option Explicit DIM DIM DIM

This document contains a VBScript that uses ADSI to create a new user in an Active Directory domain. It sets variables for the domain name, user name, full name, description, and password. It then uses the GetObject and Create methods to get a reference to the domain object and create a new user object, setting the Description and FullName properties before storing the new user information. It displays a success or error message depending on if the user was successfully created or if an error occurred.

Uploaded by

radutari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

D:\Codigo Fuente\Windows Scripting Hosting\Terminado\NewUsers.

vbs

mircoles, 15 de junio de 2016 01:43 p.m.

'************************************************
' File: NewUser.vbs (WSH sample in VBScript)
' Author: Gnter Born
'
' Uses ADSI to create a new user in Windows NT/2000.
'************************************************
Option Explicit
DIM oDomain, oUser
DIM name, fullname, descript, passw
DIM domain, title
domain = "//REDD"
name = "Bill"
fullname = "Bill Brown"
descript = "My favorite user"
passw = "Gateway"
title = "ADSI sample - by Gnter Born"
MsgBox "Create new user " & name, vbOKonly, title
On Error Resume Next
Set oDomain = GetObject("WinNT:" & domain)
If err.number <> 0 Then
MsgBox "Error: " & err.number & vbCRLF & err.description & _
vbCRLF & "domain probably not found...", _
vbOKonly+vbCritical, _
"Error connecting to " & domain
WScript.Quit ' Sorry, that's the end ...
End if
' Now we try to create the user object and set the properties
Set oUser = oDomain.Create("user", name)
' here we may set a few property values
oUser.Description = descript ' description of user
oUser.FullName = fullname ' Full name of user
oUser.SetInfo ' Store settings
If err.number = 0 Then ' Success?
MsgBox "User " & name & " created", vbOKonly, title
Else ' a problem ###
If err.number = -2147022672 Then
MsgBox "User " & name & " already exists", _
vbOKonly+vbCritical, _
"Error creating user " & name
Else
MsgBox "Error: " & err.number & vbCRLF & err.description, _
vbOKonly+vbCritical, _
"Error creating user " & name
End if
End if
Set oUser = Nothing
Set oDomain = Nothing
' End

-1-

You might also like