[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Cryptic Error when running VBScript

Posted on 2009-02-09
20
Medium Priority
?
877 Views
Last Modified: 2012-06-22
I have created a script to facilitate the new user creation process in our domain.  The purpose of the script it to create the user, set all necessary properties, create the home directory, share the home directory, set permissions on the home directory, set Communication server properties and create the Exchange mailbox.  I finally have everything working, but there is an error that pops up every time I hit "submit" button on the form.  The error has been there since the very beginning of making this script and I'm not sure what is causing it.  As I said, everything appears to work as it's supposed to, it's just annoying that the error has to pop every time the script is run.  The error is: Alert - Unexpected Error 8000500C(-2147463156).

I appreciate any help that can be provided.

Here is my script:
<html> 
<HTA:APPLICATION 
APPLICATIONNAME="Domain AD Account Creation" 
SCROLL="no" 
SINGLEINSTANCE="yes" 
WINDOWSTATE="normal" 
> 
<head> 
<title>Domain User Account Creation Form</title> 
<style type="text/css"> 
    <!-- 
body,td,th {
        font-family: Arial, Helvetica, sans-serif;
        background-color: #FFFFFF;
    } 
.style2 { font-family: Arial, Helvetica, sans-serif; 
font-size: 13.5pt; 
color: #FF0000; 
font-weight: bold; 
} 
    #Select1
    {
        width: 167px;
    }
    #jobtitle
    {
        width: 220px;
    }
--> 
</style> 
 
<script type="text/vbscript"> 
 
'This section is the error reporting for the application 
 
Sub CreateAccount 
Dim strFinitial
Dim strFirst
Dim strLast
Dim strPassword
Dim strDisplay
Dim strCN
Dim strUser
Dim strTitle
Dim objFolder
Dim objObject
 
strFinitial = TextBox1.Value 
If strFinitial = "" Then 
MsgBox "You're missing required fields - First Initial",64, "Alert" 
Exit Sub 
End If 
 
strFirst = TextBox2.Value 
If strFirst = "" Then 
MsgBox "You're missing required fields - First Name",64, "Alert" 
Exit Sub 
End If 
 
strLast = TextBox3.Value 
If strLast = "" Then 
MsgBox "You're missing required fields - Last Name",64, "Alert" 
Exit Sub 
End If 
 
strPassword = TextBox4.Value 
If strPassword = "" Then 
MsgBox "You're missing required fields - Password",64, "Alert" 
Exit Sub 
End If
 
strTitle = JobTitle.Value 
If strTitle = "" Then 
MsgBox "You're missing required fields - Job Title",64, "Alert" 
Exit Sub 
End If  
 
strDisplay = strFirst & " " & strLast 
strCN = strFirst & " " & strLast 
strUser = strFinitial & "" & strLast
 
Const ADS_UF_ACCOUNTDISABLE = 2 
Const ADS_PROPERTY_UPDATE = 2 
        
' This section will create the user & set part of the General Page. 
On Error Resume Next
Set objOU = GetObject("LDAP://CN=Users,DC=mydomainname,DC=com") 
 
If Err Then AdsiErr()
'On Error GoTo Handler
 
Set objUser = objOU.Create("User", "cn=" & strCN) 
 
If Err Then AdsiErr()   
'On Error GoTo Handler
 
objUser.Put "sAMAccountName", LCase(strUser) 
objUser.Put "userPrincipalName", strUser & "@mydomainname.com" 
objUser.Put "givenName", strFirst 
objUser.Put "sn", strLast
objUser.Put "company", "My Company Name"
objUser.Put "countryCode", "840" 
objUser.Put "c", "US"
objUser.Put "displayName", strDisplay
objUser.Put "title", strTitle 
objUser.SetInfo
objUser.Put "userAccountControl", "512"
objUser.SetInfo
objUser.SetPassword(strPassword)
objUser.accountdisabled = False
objUser.SetInfo
 
'This Section Will Add the user to the Employees Group 
Const ADS_PROPERTY_APPEND = 3 
Set objGroup = GetObject("LDAP://cn=Employees,cn=Users,dc=mydomainname,dc=com") 
objGroup.PutEx ADS_PROPERTY_APPEND, "member", Array("cn=" & strCN & ",CN=Users,dc=mydomainname,dc=com") 
objGroup.SetInfo  
 
' This section sets the login script 
objUser.Put "scriptPath", "script.vbs"
objUser.SetInfo
 
' This section sets the users home drive Information 
objUser.Put "homeDirectory", "\\nt4\" & strUser
objUser.Put "homeDrive", "H:" 
objUser.SetInfo 
objUser.GetInfo
intUserFlags = objUser.Get("userAccountControl")
intNewUserFlags = intUserFlags Or UF_DONT_EXPIRE_PASSWD
objUser.Put "userAccountControl", intNewUSerFlags
objUser.SetInfo 
 
'This Section will Create The Users Home Drive on \\nt4\Users
Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objFolder = objFSO.CreateFolder("\\nt4\f$\users\users\" & strUser)  
Set FservObj = GetObject("WinNT://DOMAINNAME/NT4/lanmanserver")
Set newshare = FservObj.create("fileshare",strUser)
newshare.path = "f:\users\users\" & strUser
newshare.Setinfo
 
If Err Then AdsiErr()
 
'This section sets share and NTFS permissions on the home directory
Set objShell = CreateObject("WScript.Shell") 
objShell.Run "XCACLS \\nt4\f$\users\users\" & strUser & " /T /G domain\" & strUser & ":C ""domain\Domain Admins"":F /y",1 ,True
objShell.Run "SETACL -on \\nt4\" & strUser & " -ot shr -actn ace -ace n:domain\" & strUser & ";p:change -ace n:""domain\Domain Admins"";p:full"
 
' This section creates the Exchange mailbox
Set objOU = GetObject("LDAP://CN=" & strCN & ",CN=Users,DC=mydomainname,DC=com")
objUser.Put "HomeMDB", "CN=Mailbox Store (EXCH2K3),CN=First Storage Group,CN=InformationStore,CN=EXCH2K3,CN=Servers,CN=DOMAIN,CN=Administrative Groups,CN=Company Name,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=mydomainname,DC=com"
objUser.Put "mailnickname",strUser
objUser.Put "mDBUseDefaults", TRUE
objUser.Put "mail",strUser & "@mydomainname.com"
objUser.SetInfo
 
' This section sets the Communication server stuff
Set objUser = GetObject("LDAP://CN=" & strCN & ",CN=Users,DC=mydomainname,DC=com")
strPrimaryUserAddress = "sip:" & objUser.get("mail")
nArchivingEnabled = 0
nOptionFlags = 256
strPrimaryHomeServer = "CN=LC Services,CN=Microsoft,CN=CHATTERBOX,CN=Pools,CN=RTC Service,CN=Microsoft,CN=System,DC=mydomainname,DC=com"
objUser.put "msRTCSIP-PrimaryUserAddress", strPrimaryUserAddress
objUser.put "msRTCSIP-ArchivingEnabled", nArchivingEnabled
objUser.put "msRTCSIP-OptionFlags", nOptionFlags
objUser.put "msRTCSIP-PrimaryHomeServer", strPrimaryHomeServer
objUser.put "msRTCSIP-UserEnabled", True
objUser.setinfo
 
' The end notification message
MsgBox "User has been created" & vbNewLine & "Employee Name: " & strCN & vbNewLine & "Username: " & strUser & vbNewLine & "Job Title: " & strTitle & vbNewLine & "Home Directory Created and Shared" & vbNewLine & "Exchange Mailbox Created" & vbNewLine & "Communication Server Enabled",64, "Alert" 
End Sub
 
Sub AdsiErr()
'AdsiErr()
        Dim s
        Dim e
 
        If Err.Number = &H800708B0 Then
                WScript.Echo "The user " & strUser & " already exists."
                MsgBox "The user " & strUser & " already exists.",64, "Alert"  
        Elseif Err.Number = &H80070035 Then
                MsgBox "Computer not found.  Check the ADsPath and try again",64, "Alert"
        Elseif Err.Number = "-2147022672" Then
                MsgBox "UserID already exists.",64, "Alert"
        Else
        e = Hex(Err.Number)
                MsgBox "Unexpected Error " & e & "(" & Err.Number & ")",64, "Alert"
        End If
        WScript.Quit
 
End Sub
 
Sub Reload 
 
location.Reload(True) 
End Sub 
 
Sub bodyLoaded() 
 
window.ResizeTo 510,545 ' WIDTH, HEIGHT 
 
End Sub 
 
</script> 
<script language="javascript" type="text/javascript">
// <!CDATA[
 
    function Select1_onclick() {
 
    }
 
// ]]>
</script>
</head> 
<body onLoad="bodyLoaded()"> 
<p align="center"><img src="hbitech.jpg" style="height: 142px; width: 136px"></p> 
<p class="style2" align="left">Tech<font color="#FF0000"> </font>Domain User Account Creation Form<font color="#FF0000">            &nbsp 
<table border="0" align="left" height="59" style="width: 352px"> 
<tr> 
<td width="94" height="14">First Initial:</td> 
<td width="173" height="14"><input type="text" name="textbox1" size="1" 
        maxlength="2" style="width: 20px"></td> 
</tr> 
<tr> 
<td width="94" height="14">First Name:</td> 
<td width="173" height="14"><input type="text" name="textbox2" size="23" 
        style="width: 220px"></td>  
</tr> 
<tr> 
<td width="94" height="14">Last Name: </td> 
<td width="173" height="14"><input type="text" name="textbox3" size="23" 
        style="width: 220px"></td>
</tr> 
<tr> 
<td width="94" height="14">Job Title:</td> 
<td width="173" height="14">
    <select name="jobtitle" onclick="return Select1_onclick()" style="width: 220px">
        <option value=" "> </option>
        <option value="Assistant Project Manager">Assistant Project Manager</option>
        <option value="Assistant Site Manager">Assistant Site Manager</option>
        <option value="Assistant Site Manager Trainee">Assistant Site Manager Trainee</option>
        <option value="Carpenter">Carpenter</option>
        <option value="Contracts Manager">Contracts Manager</option>
        <option value="Estimator">Estimator</option>
        <option value="Executive Assistant">Executive Assistant</option>
        <option value="Field Administrative Assistant">Field Administrative Assistant</option>
        <option value="Field Office Manager">Field Office Manager</option>
        <option value="Project Accountant">Project Accountant</option>
        <option value="Project Engineer">Project Engineer</option>
        <option value="Project Manager">Project Manager</option>
        <option value="Senior Estimator">Senior Estimator</option>
        <option value="Senior Project Manager">Senior Project Manager</option>
        <option value="Site Manager">Site Manager</option>
        <option value="Superintendent">Superintendent</option>
    </select></td>
</tr> 
<tr> 
<td width="94" height="14">Password: </td> 
<td width="173" height="14"><input type="text" name="textbox4" size="23" 
        style="width: 220px"></td> 
</table> 
 
<br> 
<br> 
<br> 
<br> 
<p> 
<br> 
<br> 
<br> 
</p> 
<p> 
<input type="button" name="Submit" value="Submit" onClick="CreateAccount"> 
</p> 
<p>
<input id="reloadbutton" class="button" type="reset" value="Clear Form" name="reload_button" onClick="Reload">                                        <font </p> 
<p> 
<input type="button" value=" Exit " name="close_button" onClick="Self.Close"> 
</p> 
</body> 
</html>

Open in new window

0
Comment
Question by:HarkinsIT
  • 9
  • 7
  • 3
  • +1
20 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 23594153
Hi, what line does the script say you have the error on?

Rob.
0
 

Author Comment

by:HarkinsIT
ID: 23594194
It doesn't say.  See the attached file for the complete error.
error.jpg
0
 
LVL 14

Expert Comment

by:rejoinder
ID: 23594520
Because the script is creating the error message, can you use the modified script below.  Modify the script with your company info and run the script again.  Please post the error message as you did above.
<html> 
<HTA:APPLICATION 
APPLICATIONNAME="Domain AD Account Creation" 
SCROLL="no" 
SINGLEINSTANCE="yes" 
WINDOWSTATE="normal" 
> 
<head> 
<title>Domain User Account Creation Form</title> 
<style type="text/css"> 
    <!-- 
body,td,th {
        font-family: Arial, Helvetica, sans-serif;
        background-color: #FFFFFF;
    } 
.style2 { font-family: Arial, Helvetica, sans-serif; 
font-size: 13.5pt; 
color: #FF0000; 
font-weight: bold; 
} 
    #Select1
    {
        width: 167px;
    }
    #jobtitle
    {
        width: 220px;
    }
--> 
</style> 
 
<script type="text/vbscript"> 
 
'This section is the error reporting for the application 
 
Sub CreateAccount 
Dim strFinitial
Dim strFirst
Dim strLast
Dim strPassword
Dim strDisplay
Dim strCN
Dim strUser
Dim strTitle
Dim objFolder
Dim objObject
 
strFinitial = TextBox1.Value 
If strFinitial = "" Then 
MsgBox "You're missing required fields - First Initial",64, "Alert" 
Exit Sub 
End If 
 
strFirst = TextBox2.Value 
If strFirst = "" Then 
MsgBox "You're missing required fields - First Name",64, "Alert" 
Exit Sub 
End If 
 
strLast = TextBox3.Value 
If strLast = "" Then 
MsgBox "You're missing required fields - Last Name",64, "Alert" 
Exit Sub 
End If 
 
strPassword = TextBox4.Value 
If strPassword = "" Then 
MsgBox "You're missing required fields - Password",64, "Alert" 
Exit Sub 
End If
 
strTitle = JobTitle.Value 
If strTitle = "" Then 
MsgBox "You're missing required fields - Job Title",64, "Alert" 
Exit Sub 
End If  
 
strDisplay = strFirst & " " & strLast 
strCN = strFirst & " " & strLast 
strUser = strFinitial & "" & strLast
 
Const ADS_UF_ACCOUNTDISABLE = 2 
Const ADS_PROPERTY_UPDATE = 2 
        
' This section will create the user & set part of the General Page. 
On Error Resume Next
Set objOU = GetObject("LDAP://CN=Users,DC=mydomainname,DC=com") 
 
If Err Then AdsiErr("Setting objOU")
err.clear
'On Error GoTo Handler
 
Set objUser = objOU.Create("User", "cn=" & strCN) 
 
If Err Then AdsiErr("Setting objUser") 
err.clear  
'On Error GoTo Handler
 
objUser.Put "sAMAccountName", LCase(strUser) 
objUser.Put "userPrincipalName", strUser & "@mydomainname.com" 
objUser.Put "givenName", strFirst 
objUser.Put "sn", strLast
objUser.Put "company", "My Company Name"
objUser.Put "countryCode", "840" 
objUser.Put "c", "US"
objUser.Put "displayName", strDisplay
objUser.Put "title", strTitle 
objUser.SetInfo
objUser.Put "userAccountControl", "512"
objUser.SetInfo
objUser.SetPassword(strPassword)
objUser.accountdisabled = False
objUser.SetInfo
 
If Err Then AdsiErr("Putting user info in AD")
err.clear
 
'This Section Will Add the user to the Employees Group 
Const ADS_PROPERTY_APPEND = 3 
Set objGroup = GetObject("LDAP://cn=Employees,cn=Users,dc=mydomainname,dc=com") 
objGroup.PutEx ADS_PROPERTY_APPEND, "member", Array("cn=" & strCN & ",CN=Users,dc=mydomainname,dc=com") 
objGroup.SetInfo  
 
If Err Then AdsiErr("Putting user info in AD")
err.clear
 
' This section sets the login script 
objUser.Put "scriptPath", "script.vbs"
objUser.SetInfo
 
If Err Then AdsiErr("Setting login script")
err.clear
 
 
' This section sets the users home drive Information 
objUser.Put "homeDirectory", "\\nt4\" & strUser
objUser.Put "homeDrive", "H:" 
objUser.SetInfo 
objUser.GetInfo
intUserFlags = objUser.Get("userAccountControl")
intNewUserFlags = intUserFlags Or UF_DONT_EXPIRE_PASSWD
objUser.Put "userAccountControl", intNewUSerFlags
objUser.SetInfo 
 
If Err Then AdsiErr("Setting home drive info")
err.clear
 
 
'This Section will Create The Users Home Drive on \\nt4\Users
Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objFolder = objFSO.CreateFolder("\\nt4\f$\users\users\" & strUser)  
Set FservObj = GetObject("WinNT://DOMAINNAME/NT4/lanmanserver")
Set newshare = FservObj.create("fileshare",strUser)
newshare.path = "f:\users\users\" & strUser
newshare.Setinfo
 
If Err Then AdsiErr("Creating home drive")
err.clear
 
'This section sets share and NTFS permissions on the home directory
Set objShell = CreateObject("WScript.Shell") 
objShell.Run "XCACLS \\nt4\f$\users\users\" & strUser & " /T /G domain\" & strUser & ":C ""domain\Domain Admins"":F /y",1 ,True
objShell.Run "SETACL -on \\nt4\" & strUser & " -ot shr -actn ace -ace n:domain\" & strUser & ";p:change -ace n:""domain\Domain Admins"";p:full"
 
If Err Then AdsiErr("Setting permissions")
err.clear
 
' This section creates the Exchange mailbox
Set objOU = GetObject("LDAP://CN=" & strCN & ",CN=Users,DC=mydomainname,DC=com")
objUser.Put "HomeMDB", "CN=Mailbox Store (EXCH2K3),CN=First Storage Group,CN=InformationStore,CN=EXCH2K3,CN=Servers,CN=DOMAIN,CN=Administrative Groups,CN=Company Name,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=mydomainname,DC=com"
objUser.Put "mailnickname",strUser
objUser.Put "mDBUseDefaults", TRUE
objUser.Put "mail",strUser & "@mydomainname.com"
objUser.SetInfo
 
If Err Then AdsiErr("Creating mailbox")
err.clear
 
 
' This section sets the Communication server stuff
Set objUser = GetObject("LDAP://CN=" & strCN & ",CN=Users,DC=mydomainname,DC=com")
strPrimaryUserAddress = "sip:" & objUser.get("mail")
nArchivingEnabled = 0
nOptionFlags = 256
strPrimaryHomeServer = "CN=LC Services,CN=Microsoft,CN=CHATTERBOX,CN=Pools,CN=RTC Service,CN=Microsoft,CN=System,DC=mydomainname,DC=com"
objUser.put "msRTCSIP-PrimaryUserAddress", strPrimaryUserAddress
objUser.put "msRTCSIP-ArchivingEnabled", nArchivingEnabled
objUser.put "msRTCSIP-OptionFlags", nOptionFlags
objUser.put "msRTCSIP-PrimaryHomeServer", strPrimaryHomeServer
objUser.put "msRTCSIP-UserEnabled", True
objUser.setinfo
 
If Err Then AdsiErr("Setting communication server info")
err.clear
 
 
' The end notification message
MsgBox "User has been created" & vbNewLine & "Employee Name: " & strCN & vbNewLine & "Username: " & strUser & vbNewLine & "Job Title: " & strTitle & vbNewLine & "Home Directory Created and Shared" & vbNewLine & "Exchange Mailbox Created" & vbNewLine & "Communication Server Enabled",64, "Alert" 
End Sub
 
Sub AdsiErr(strErrorInSection)
'AdsiErr()
        Dim s
        Dim e
 
        If Err.Number = &H800708B0 Then
                MsgBox "The user " & strUser & " already exists." & vbCRLF & strErrorInSection,64, "Alert"  
        Elseif Err.Number = &H80070035 Then
                MsgBox "Computer not found.  Check the ADsPath and try again" & vbCRLF & strErrorInSection,64, "Alert"
        Elseif Err.Number = "-2147022672" Then
                MsgBox "UserID already exists." & vbCRLF & strErrorInSection,64, "Alert"
        Else
        e = Hex(Err.Number)
                MsgBox "Unexpected Error " & e & "(" & Err.Number & ")" & vbCRLF & strErrorInSection,64, "Alert"
        End If
        'WScript.Quit
 
End Sub
 
Sub Reload 
 
location.Reload(True) 
End Sub 
 
Sub bodyLoaded() 
 
window.ResizeTo 510,545 ' WIDTH, HEIGHT 
 
End Sub 
 
</script> 
<script language="javascript" type="text/javascript">
// <!CDATA[
 
    function Select1_onclick() {
 
    }
 
// ]]>
</script>
</head> 
<body onLoad="bodyLoaded()"> 
<p align="center"><img src="hbitech.jpg" style="height: 142px; width: 136px"></p> 
<p class="style2" align="left">Tech<font color="#FF0000"> </font>Domain User Account Creation Form<font color="#FF0000">            &nbsp 
<table border="0" align="left" height="59" style="width: 352px"> 
<tr> 
<td width="94" height="14">First Initial:</td> 
<td width="173" height="14"><input type="text" name="textbox1" size="1" 
        maxlength="2" style="width: 20px"></td> 
</tr> 
<tr> 
<td width="94" height="14">First Name:</td> 
<td width="173" height="14"><input type="text" name="textbox2" size="23" 
        style="width: 220px"></td>  
</tr> 
<tr> 
<td width="94" height="14">Last Name: </td> 
<td width="173" height="14"><input type="text" name="textbox3" size="23" 
        style="width: 220px"></td>
</tr> 
<tr> 
<td width="94" height="14">Job Title:</td> 
<td width="173" height="14">
    <select name="jobtitle" onclick="return Select1_onclick()" style="width: 220px">
        <option value=" "> </option>
        <option value="Assistant Project Manager">Assistant Project Manager</option>
        <option value="Assistant Site Manager">Assistant Site Manager</option>
        <option value="Assistant Site Manager Trainee">Assistant Site Manager Trainee</option>
        <option value="Carpenter">Carpenter</option>
        <option value="Contracts Manager">Contracts Manager</option>
        <option value="Estimator">Estimator</option>
        <option value="Executive Assistant">Executive Assistant</option>
        <option value="Field Administrative Assistant">Field Administrative Assistant</option>
        <option value="Field Office Manager">Field Office Manager</option>
        <option value="Project Accountant">Project Accountant</option>
        <option value="Project Engineer">Project Engineer</option>
        <option value="Project Manager">Project Manager</option>
        <option value="Senior Estimator">Senior Estimator</option>
        <option value="Senior Project Manager">Senior Project Manager</option>
        <option value="Site Manager">Site Manager</option>
        <option value="Superintendent">Superintendent</option>
    </select></td>
</tr> 
<tr> 
<td width="94" height="14">Password: </td> 
<td width="173" height="14"><input type="text" name="textbox4" size="23" 
        style="width: 220px"></td> 
</table> 
 
<br> 
<br> 
<br> 
<br> 
<p> 
<br> 
<br> 
<br> 
</p> 
<p> 
<input type="button" name="Submit" value="Submit" onClick="CreateAccount"> 
</p> 
<p>
<input id="reloadbutton" class="button" type="reset" value="Clear Form" name="reload_button" onClick="Reload">                                        <font </p> 
<p> 
<input type="button" value=" Exit " name="close_button" onClick="Self.Close"> 
</p> 
</body> 
</html>

Open in new window

0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:HarkinsIT
ID: 23594846
OK, now I know where the problem lies.  Not sure exactly what the problem is though.  Attached is the new error.

Thanks for the help.
-Chris
newerror.jpg
0
 
LVL 14

Expert Comment

by:rejoinder
ID: 23594889
That part of the code is broken into three sections; adding the sam account name and other details, next the account control is set to "512" and lastly the password is set.
As a test, can you change line 109 to read;
objUser.Put "userAccountControl", 512
Basically take out the quotes around 512 and run the script again.
0
 

Author Comment

by:HarkinsIT
ID: 23594905
OK, I made that change and received the same error.

Thanks
0
 
LVL 14

Expert Comment

by:rejoinder
ID: 23594934
This is the same code from above but this time it will break apart that three section block of code so we can see which section is to blame.
<html> 
<HTA:APPLICATION 
APPLICATIONNAME="Domain AD Account Creation" 
SCROLL="no" 
SINGLEINSTANCE="yes" 
WINDOWSTATE="normal" 
> 
<head> 
<title>Domain User Account Creation Form</title> 
<style type="text/css"> 
    <!-- 
body,td,th {
        font-family: Arial, Helvetica, sans-serif;
        background-color: #FFFFFF;
    } 
.style2 { font-family: Arial, Helvetica, sans-serif; 
font-size: 13.5pt; 
color: #FF0000; 
font-weight: bold; 
} 
    #Select1
    {
        width: 167px;
    }
    #jobtitle
    {
        width: 220px;
    }
--> 
</style> 
 
<script type="text/vbscript"> 
 
'This section is the error reporting for the application 
 
Sub CreateAccount 
Dim strFinitial
Dim strFirst
Dim strLast
Dim strPassword
Dim strDisplay
Dim strCN
Dim strUser
Dim strTitle
Dim objFolder
Dim objObject
 
strFinitial = TextBox1.Value 
If strFinitial = "" Then 
MsgBox "You're missing required fields - First Initial",64, "Alert" 
Exit Sub 
End If 
 
strFirst = TextBox2.Value 
If strFirst = "" Then 
MsgBox "You're missing required fields - First Name",64, "Alert" 
Exit Sub 
End If 
 
strLast = TextBox3.Value 
If strLast = "" Then 
MsgBox "You're missing required fields - Last Name",64, "Alert" 
Exit Sub 
End If 
 
strPassword = TextBox4.Value 
If strPassword = "" Then 
MsgBox "You're missing required fields - Password",64, "Alert" 
Exit Sub 
End If
 
strTitle = JobTitle.Value 
If strTitle = "" Then 
MsgBox "You're missing required fields - Job Title",64, "Alert" 
Exit Sub 
End If  
 
strDisplay = strFirst & " " & strLast 
strCN = strFirst & " " & strLast 
strUser = strFinitial & "" & strLast
 
Const ADS_UF_ACCOUNTDISABLE = 2 
Const ADS_PROPERTY_UPDATE = 2 
        
' This section will create the user & set part of the General Page. 
On Error Resume Next
Set objOU = GetObject("LDAP://CN=Users,DC=mydomainname,DC=com") 
 
If Err Then AdsiErr("Setting objOU")
err.clear
'On Error GoTo Handler
 
Set objUser = objOU.Create("User", "cn=" & strCN) 
 
If Err Then AdsiErr("Setting objUser") 
err.clear  
'On Error GoTo Handler
 
objUser.Put "sAMAccountName", LCase(strUser) 
objUser.Put "userPrincipalName", strUser & "@mydomainname.com" 
objUser.Put "givenName", strFirst 
objUser.Put "sn", strLast
objUser.Put "company", "My Company Name"
objUser.Put "countryCode", "840" 
objUser.Put "c", "US"
objUser.Put "displayName", strDisplay
objUser.Put "title", strTitle 
objUser.SetInfo
 
If Err Then AdsiErr("Putting user details in AD")
err.clear
 
objUser.Put "userAccountControl", 512
objUser.SetInfo
 
If Err Then AdsiErr("Setting user account control")
err.clear
 
objUser.SetPassword(strPassword)
objUser.accountdisabled = False
objUser.SetInfo
 
If Err Then AdsiErr("Setting password")
err.clear
 
'This Section Will Add the user to the Employees Group 
Const ADS_PROPERTY_APPEND = 3 
Set objGroup = GetObject("LDAP://cn=Employees,cn=Users,dc=mydomainname,dc=com") 
objGroup.PutEx ADS_PROPERTY_APPEND, "member", Array("cn=" & strCN & ",CN=Users,dc=mydomainname,dc=com") 
objGroup.SetInfo  
 
If Err Then AdsiErr("Putting user info in AD")
err.clear
 
' This section sets the login script 
objUser.Put "scriptPath", "script.vbs"
objUser.SetInfo
 
If Err Then AdsiErr("Setting login script")
err.clear
 
 
' This section sets the users home drive Information 
objUser.Put "homeDirectory", "\\nt4\" & strUser
objUser.Put "homeDrive", "H:" 
objUser.SetInfo 
objUser.GetInfo
intUserFlags = objUser.Get("userAccountControl")
intNewUserFlags = intUserFlags Or UF_DONT_EXPIRE_PASSWD
objUser.Put "userAccountControl", intNewUSerFlags
objUser.SetInfo 
 
If Err Then AdsiErr("Setting home drive info")
err.clear
 
 
'This Section will Create The Users Home Drive on \\nt4\Users
Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objFolder = objFSO.CreateFolder("\\nt4\f$\users\users\" & strUser)  
Set FservObj = GetObject("WinNT://DOMAINNAME/NT4/lanmanserver")
Set newshare = FservObj.create("fileshare",strUser)
newshare.path = "f:\users\users\" & strUser
newshare.Setinfo
 
If Err Then AdsiErr("Creating home drive")
err.clear
 
'This section sets share and NTFS permissions on the home directory
Set objShell = CreateObject("WScript.Shell") 
objShell.Run "XCACLS \\nt4\f$\users\users\" & strUser & " /T /G domain\" & strUser & ":C ""domain\Domain Admins"":F /y",1 ,True
objShell.Run "SETACL -on \\nt4\" & strUser & " -ot shr -actn ace -ace n:domain\" & strUser & ";p:change -ace n:""domain\Domain Admins"";p:full"
 
If Err Then AdsiErr("Setting permissions")
err.clear
 
' This section creates the Exchange mailbox
Set objOU = GetObject("LDAP://CN=" & strCN & ",CN=Users,DC=mydomainname,DC=com")
objUser.Put "HomeMDB", "CN=Mailbox Store (EXCH2K3),CN=First Storage Group,CN=InformationStore,CN=EXCH2K3,CN=Servers,CN=DOMAIN,CN=Administrative Groups,CN=Company Name,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=mydomainname,DC=com"
objUser.Put "mailnickname",strUser
objUser.Put "mDBUseDefaults", TRUE
objUser.Put "mail",strUser & "@mydomainname.com"
objUser.SetInfo
 
If Err Then AdsiErr("Creating mailbox")
err.clear
 
 
' This section sets the Communication server stuff
Set objUser = GetObject("LDAP://CN=" & strCN & ",CN=Users,DC=mydomainname,DC=com")
strPrimaryUserAddress = "sip:" & objUser.get("mail")
nArchivingEnabled = 0
nOptionFlags = 256
strPrimaryHomeServer = "CN=LC Services,CN=Microsoft,CN=CHATTERBOX,CN=Pools,CN=RTC Service,CN=Microsoft,CN=System,DC=mydomainname,DC=com"
objUser.put "msRTCSIP-PrimaryUserAddress", strPrimaryUserAddress
objUser.put "msRTCSIP-ArchivingEnabled", nArchivingEnabled
objUser.put "msRTCSIP-OptionFlags", nOptionFlags
objUser.put "msRTCSIP-PrimaryHomeServer", strPrimaryHomeServer
objUser.put "msRTCSIP-UserEnabled", True
objUser.setinfo
 
If Err Then AdsiErr("Setting communication server info")
err.clear
 
 
' The end notification message
MsgBox "User has been created" & vbNewLine & "Employee Name: " & strCN & vbNewLine & "Username: " & strUser & vbNewLine & "Job Title: " & strTitle & vbNewLine & "Home Directory Created and Shared" & vbNewLine & "Exchange Mailbox Created" & vbNewLine & "Communication Server Enabled",64, "Alert" 
End Sub
 
Sub AdsiErr(strErrorInSection)
'AdsiErr()
        Dim s
        Dim e
 
        If Err.Number = &H800708B0 Then
                MsgBox "The user " & strUser & " already exists." & vbCRLF & strErrorInSection,64, "Alert"  
        Elseif Err.Number = &H80070035 Then
                MsgBox "Computer not found.  Check the ADsPath and try again" & vbCRLF & strErrorInSection,64, "Alert"
        Elseif Err.Number = "-2147022672" Then
                MsgBox "UserID already exists." & vbCRLF & strErrorInSection,64, "Alert"
        Else
        e = Hex(Err.Number)
                MsgBox "Unexpected Error " & e & "(" & Err.Number & ")" & vbCRLF & strErrorInSection,64, "Alert"
        End If
        'WScript.Quit
 
End Sub
 
Sub Reload 
 
location.Reload(True) 
End Sub 
 
Sub bodyLoaded() 
 
window.ResizeTo 510,545 ' WIDTH, HEIGHT 
 
End Sub 
 
</script> 
<script language="javascript" type="text/javascript">
// <!CDATA[
 
    function Select1_onclick() {
 
    }
 
// ]]>
</script>
</head> 
<body onLoad="bodyLoaded()"> 
<p align="center"><img src="hbitech.jpg" style="height: 142px; width: 136px"></p> 
<p class="style2" align="left">Tech<font color="#FF0000"> </font>Domain User Account Creation Form<font color="#FF0000">            &nbsp 
<table border="0" align="left" height="59" style="width: 352px"> 
<tr> 
<td width="94" height="14">First Initial:</td> 
<td width="173" height="14"><input type="text" name="textbox1" size="1" 
        maxlength="2" style="width: 20px"></td> 
</tr> 
<tr> 
<td width="94" height="14">First Name:</td> 
<td width="173" height="14"><input type="text" name="textbox2" size="23" 
        style="width: 220px"></td>  
</tr> 
<tr> 
<td width="94" height="14">Last Name: </td> 
<td width="173" height="14"><input type="text" name="textbox3" size="23" 
        style="width: 220px"></td>
</tr> 
<tr> 
<td width="94" height="14">Job Title:</td> 
<td width="173" height="14">
    <select name="jobtitle" onclick="return Select1_onclick()" style="width: 220px">
        <option value=" "> </option>
        <option value="Assistant Project Manager">Assistant Project Manager</option>
        <option value="Assistant Site Manager">Assistant Site Manager</option>
        <option value="Assistant Site Manager Trainee">Assistant Site Manager Trainee</option>
        <option value="Carpenter">Carpenter</option>
        <option value="Contracts Manager">Contracts Manager</option>
        <option value="Estimator">Estimator</option>
        <option value="Executive Assistant">Executive Assistant</option>
        <option value="Field Administrative Assistant">Field Administrative Assistant</option>
        <option value="Field Office Manager">Field Office Manager</option>
        <option value="Project Accountant">Project Accountant</option>
        <option value="Project Engineer">Project Engineer</option>
        <option value="Project Manager">Project Manager</option>
        <option value="Senior Estimator">Senior Estimator</option>
        <option value="Senior Project Manager">Senior Project Manager</option>
        <option value="Site Manager">Site Manager</option>
        <option value="Superintendent">Superintendent</option>
    </select></td>
</tr> 
<tr> 
<td width="94" height="14">Password: </td> 
<td width="173" height="14"><input type="text" name="textbox4" size="23" 
        style="width: 220px"></td> 
</table> 
 
<br> 
<br> 
<br> 
<br> 
<p> 
<br> 
<br> 
<br> 
</p> 
<p> 
<input type="button" name="Submit" value="Submit" onClick="CreateAccount"> 
</p> 
<p>
<input id="reloadbutton" class="button" type="reset" value="Clear Form" name="reload_button" onClick="Reload">                                        <font </p> 
<p> 
<input type="button" value=" Exit " name="close_button" onClick="Self.Close"> 
</p> 
</body> 
</html>

Open in new window

0
 
LVL 14

Expert Comment

by:rejoinder
ID: 23594956
Just in case its a password issue - have you double checked that the password you are feeding the script meets the complexity requirements and length of your domain?
0
 

Author Comment

by:HarkinsIT
ID: 23595032
Attached is the latest error.  

Yeah, the password I am using is our standard one that we assign to new users initially.

Thanks again!
error3.jpg
0
 

Author Comment

by:HarkinsIT
ID: 23595089
This error happened right after I hit OK on the last one.
error4.jpg
0
 

Author Comment

by:HarkinsIT
ID: 23595169
I found that if I have no quotes around the 512 as you instructed above, I get only the "Setting User Account Control" error but if I put the quotes around the 512, I get that error and the "Setting Password" one.

Hmmm.

0
 
LVL 65

Expert Comment

by:RobSampson
ID: 23595328
Perhaps you need to enable the account before setting the useraccountcontrol....I've moved the objUser.accountdisabled line above that now...

Rob.
<html> 
<HTA:APPLICATION 
APPLICATIONNAME="Domain AD Account Creation" 
SCROLL="no" 
SINGLEINSTANCE="yes" 
WINDOWSTATE="normal" 
> 
<head> 
<title>Domain User Account Creation Form</title> 
<style type="text/css"> 
    <!-- 
body,td,th {
        font-family: Arial, Helvetica, sans-serif;
        background-color: #FFFFFF;
    } 
.style2 { font-family: Arial, Helvetica, sans-serif; 
font-size: 13.5pt; 
color: #FF0000; 
font-weight: bold; 
} 
    #Select1
    {
        width: 167px;
    }
    #jobtitle
    {
        width: 220px;
    }
--> 
</style> 
 
<script type="text/vbscript"> 
 
'This section is the error reporting for the application 
 
Sub CreateAccount 
Dim strFinitial
Dim strFirst
Dim strLast
Dim strPassword
Dim strDisplay
Dim strCN
Dim strUser
Dim strTitle
Dim objFolder
Dim objObject
 
strFinitial = TextBox1.Value 
If strFinitial = "" Then 
MsgBox "You're missing required fields - First Initial",64, "Alert" 
Exit Sub 
End If 
 
strFirst = TextBox2.Value 
If strFirst = "" Then 
MsgBox "You're missing required fields - First Name",64, "Alert" 
Exit Sub 
End If 
 
strLast = TextBox3.Value 
If strLast = "" Then 
MsgBox "You're missing required fields - Last Name",64, "Alert" 
Exit Sub 
End If 
 
strPassword = TextBox4.Value 
If strPassword = "" Then 
MsgBox "You're missing required fields - Password",64, "Alert" 
Exit Sub 
End If
 
strTitle = JobTitle.Value 
If strTitle = "" Then 
MsgBox "You're missing required fields - Job Title",64, "Alert" 
Exit Sub 
End If  
 
strDisplay = strFirst & " " & strLast 
strCN = strFirst & " " & strLast 
strUser = strFinitial & "" & strLast
 
Const ADS_UF_ACCOUNTDISABLE = 2 
Const ADS_PROPERTY_UPDATE = 2 
        
' This section will create the user & set part of the General Page. 
On Error Resume Next
Set objOU = GetObject("LDAP://CN=Users,DC=mydomainname,DC=com") 
 
If Err Then AdsiErr("Setting objOU")
err.clear
'On Error GoTo Handler
 
Set objUser = objOU.Create("User", "cn=" & strCN) 
 
If Err Then AdsiErr("Setting objUser") 
err.clear  
'On Error GoTo Handler
 
objUser.Put "sAMAccountName", LCase(strUser) 
objUser.Put "userPrincipalName", strUser & "@mydomainname.com" 
objUser.Put "givenName", strFirst 
objUser.Put "sn", strLast
objUser.Put "company", "My Company Name"
objUser.Put "countryCode", "840" 
objUser.Put "c", "US"
objUser.Put "displayName", strDisplay
objUser.Put "title", strTitle 
objUser.SetInfo
 
objUser.accountdisabled = False
objUser.SetInfo
 
If Err Then AdsiErr("Putting user details in AD")
err.clear
 
objUser.Put "userAccountControl", 512
objUser.SetInfo
 
If Err Then AdsiErr("Setting user account control")
err.clear
 
objUser.SetPassword(strPassword)
objUser.SetInfo
 
If Err Then AdsiErr("Setting password")
err.clear
 
'This Section Will Add the user to the Employees Group 
Const ADS_PROPERTY_APPEND = 3 
Set objGroup = GetObject("LDAP://cn=Employees,cn=Users,dc=mydomainname,dc=com") 
objGroup.PutEx ADS_PROPERTY_APPEND, "member", Array("cn=" & strCN & ",CN=Users,dc=mydomainname,dc=com") 
objGroup.SetInfo  
 
If Err Then AdsiErr("Putting user info in AD")
err.clear
 
' This section sets the login script 
objUser.Put "scriptPath", "script.vbs"
objUser.SetInfo
 
If Err Then AdsiErr("Setting login script")
err.clear
 
 
' This section sets the users home drive Information 
objUser.Put "homeDirectory", "\\nt4\" & strUser
objUser.Put "homeDrive", "H:" 
objUser.SetInfo 
objUser.GetInfo
intUserFlags = objUser.Get("userAccountControl")
intNewUserFlags = intUserFlags Or UF_DONT_EXPIRE_PASSWD
objUser.Put "userAccountControl", intNewUSerFlags
objUser.SetInfo 
 
If Err Then AdsiErr("Setting home drive info")
err.clear
 
 
'This Section will Create The Users Home Drive on \\nt4\Users
Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objFolder = objFSO.CreateFolder("\\nt4\f$\users\users\" & strUser)  
Set FservObj = GetObject("WinNT://DOMAINNAME/NT4/lanmanserver")
Set newshare = FservObj.create("fileshare",strUser)
newshare.path = "f:\users\users\" & strUser
newshare.Setinfo
 
If Err Then AdsiErr("Creating home drive")
err.clear
 
'This section sets share and NTFS permissions on the home directory
Set objShell = CreateObject("WScript.Shell") 
objShell.Run "XCACLS \\nt4\f$\users\users\" & strUser & " /T /G domain\" & strUser & ":C ""domain\Domain Admins"":F /y",1 ,True
objShell.Run "SETACL -on \\nt4\" & strUser & " -ot shr -actn ace -ace n:domain\" & strUser & ";p:change -ace n:""domain\Domain Admins"";p:full"
 
If Err Then AdsiErr("Setting permissions")
err.clear
 
' This section creates the Exchange mailbox
Set objOU = GetObject("LDAP://CN=" & strCN & ",CN=Users,DC=mydomainname,DC=com")
objUser.Put "HomeMDB", "CN=Mailbox Store (EXCH2K3),CN=First Storage Group,CN=InformationStore,CN=EXCH2K3,CN=Servers,CN=DOMAIN,CN=Administrative Groups,CN=Company Name,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=mydomainname,DC=com"
objUser.Put "mailnickname",strUser
objUser.Put "mDBUseDefaults", TRUE
objUser.Put "mail",strUser & "@mydomainname.com"
objUser.SetInfo
 
If Err Then AdsiErr("Creating mailbox")
err.clear
 
 
' This section sets the Communication server stuff
Set objUser = GetObject("LDAP://CN=" & strCN & ",CN=Users,DC=mydomainname,DC=com")
strPrimaryUserAddress = "sip:" & objUser.get("mail")
nArchivingEnabled = 0
nOptionFlags = 256
strPrimaryHomeServer = "CN=LC Services,CN=Microsoft,CN=CHATTERBOX,CN=Pools,CN=RTC Service,CN=Microsoft,CN=System,DC=mydomainname,DC=com"
objUser.put "msRTCSIP-PrimaryUserAddress", strPrimaryUserAddress
objUser.put "msRTCSIP-ArchivingEnabled", nArchivingEnabled
objUser.put "msRTCSIP-OptionFlags", nOptionFlags
objUser.put "msRTCSIP-PrimaryHomeServer", strPrimaryHomeServer
objUser.put "msRTCSIP-UserEnabled", True
objUser.setinfo
 
If Err Then AdsiErr("Setting communication server info")
err.clear
 
 
' The end notification message
MsgBox "User has been created" & vbNewLine & "Employee Name: " & strCN & vbNewLine & "Username: " & strUser & vbNewLine & "Job Title: " & strTitle & vbNewLine & "Home Directory Created and Shared" & vbNewLine & "Exchange Mailbox Created" & vbNewLine & "Communication Server Enabled",64, "Alert" 
End Sub
 
Sub AdsiErr(strErrorInSection)
'AdsiErr()
        Dim s
        Dim e
 
        If Err.Number = &H800708B0 Then
                MsgBox "The user " & strUser & " already exists." & vbCRLF & strErrorInSection,64, "Alert"  
        Elseif Err.Number = &H80070035 Then
                MsgBox "Computer not found.  Check the ADsPath and try again" & vbCRLF & strErrorInSection,64, "Alert"
        Elseif Err.Number = "-2147022672" Then
                MsgBox "UserID already exists." & vbCRLF & strErrorInSection,64, "Alert"
        Else
        e = Hex(Err.Number)
                MsgBox "Unexpected Error " & e & "(" & Err.Number & ")" & vbCRLF & strErrorInSection,64, "Alert"
        End If
        'WScript.Quit
 
End Sub
 
Sub Reload 
 
location.Reload(True) 
End Sub 
 
Sub bodyLoaded() 
 
window.ResizeTo 510,545 ' WIDTH, HEIGHT 
 
End Sub 
 
</script> 
<script language="javascript" type="text/javascript">
// <!CDATA[
 
    function Select1_onclick() {
 
    }
 
// ]]>
</script>
</head> 
<body onLoad="bodyLoaded()"> 
<p align="center"><img src="hbitech.jpg" style="height: 142px; width: 136px"></p> 
<p class="style2" align="left">Tech<font color="#FF0000"> </font>Domain User Account Creation Form<font color="#FF0000">            &nbsp 
<table border="0" align="left" height="59" style="width: 352px"> 
<tr> 
<td width="94" height="14">First Initial:</td> 
<td width="173" height="14"><input type="text" name="textbox1" size="1" 
        maxlength="2" style="width: 20px"></td> 
</tr> 
<tr> 
<td width="94" height="14">First Name:</td> 
<td width="173" height="14"><input type="text" name="textbox2" size="23" 
        style="width: 220px"></td>  
</tr> 
<tr> 
<td width="94" height="14">Last Name: </td> 
<td width="173" height="14"><input type="text" name="textbox3" size="23" 
        style="width: 220px"></td>
</tr> 
<tr> 
<td width="94" height="14">Job Title:</td> 
<td width="173" height="14">
    <select name="jobtitle" onclick="return Select1_onclick()" style="width: 220px">
        <option value=" "> </option>
        <option value="Assistant Project Manager">Assistant Project Manager</option>
        <option value="Assistant Site Manager">Assistant Site Manager</option>
        <option value="Assistant Site Manager Trainee">Assistant Site Manager Trainee</option>
        <option value="Carpenter">Carpenter</option>
        <option value="Contracts Manager">Contracts Manager</option>
        <option value="Estimator">Estimator</option>
        <option value="Executive Assistant">Executive Assistant</option>
        <option value="Field Administrative Assistant">Field Administrative Assistant</option>
        <option value="Field Office Manager">Field Office Manager</option>
        <option value="Project Accountant">Project Accountant</option>
        <option value="Project Engineer">Project Engineer</option>
        <option value="Project Manager">Project Manager</option>
        <option value="Senior Estimator">Senior Estimator</option>
        <option value="Senior Project Manager">Senior Project Manager</option>
        <option value="Site Manager">Site Manager</option>
        <option value="Superintendent">Superintendent</option>
    </select></td>
</tr> 
<tr> 
<td width="94" height="14">Password: </td> 
<td width="173" height="14"><input type="text" name="textbox4" size="23" 
        style="width: 220px"></td> 
</table> 
 
<br> 
<br> 
<br> 
<br> 
<p> 
<br> 
<br> 
<br> 
</p> 
<p> 
<input type="button" name="Submit" value="Submit" onClick="CreateAccount"> 
</p> 
<p>
<input id="reloadbutton" class="button" type="reset" value="Clear Form" name="reload_button" onClick="Reload">                                        <font </p> 
<p> 
<input type="button" value=" Exit " name="close_button" onClick="Self.Close"> 
</p> 
</body> 
</html>

Open in new window

0
 
LVL 14

Accepted Solution

by:
rejoinder earned 2000 total points
ID: 23595427
Odd - I wouldn't have thought that would happen.  OK can we try a few things real quick...

Please change that block of ocde to read;
Const ADS_UF_NORMAL_ACCOUNT = 512
objUser.Put "userAccountControl", ADS_UF_NORMAL_ACCOUNT

Can you comment out the line;
objUser.accountdisabled = False
0
 
LVL 14

Expert Comment

by:rejoinder
ID: 23595437
Here is a quick article talking about enabling the account;
http://techtasks.com/code/viewbookcode/1555

Please have a look at that to see if that applies to your domain.
0
 

Author Comment

by:HarkinsIT
ID: 23600331
Rob, when making that change, I still receive the "Setting User Account Control Error".

Now trying what rejoinder recommends.

Thanks!
0
 
LVL 14

Expert Comment

by:yehudaha
ID: 23600383
wich version of adsi do you have ?

http://support.microsoft.com/kb/216290
0
 

Author Comment

by:HarkinsIT
ID: 23600583
Rejoinder, changing that block of code did the trick.  Everything gets created and set as it should with no errors and the new user works perfectly.  

Thanks very much.  Is that change something I can leave permanent, or did we just set it for testing purposes?
0
 
LVL 14

Expert Comment

by:rejoinder
ID: 23603304
You bet you can make that permanent.  I hope the extra error checking will also come in handy for you as well.  :-)
0
 

Author Comment

by:HarkinsIT
ID: 23603323
Absolutely.  I will definitely keep that method handy for future projects.

Thanks for your help!
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 23606012
Wow, I have used a constant in all of my scripts for Put("userAccountControl") but I didn't think it would actually make that difference!  Oh well....nice work rejoinder.

Regards,

Rob.
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
Active Directory can easily get cluttered with unused service, user and computer accounts. In this article, I will show you the way I like to implement ADCleanup..
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question