I am relatively new to this whole ASP classic programming thing, and I am not working on a pretty complex script. Essentially the script creates a domain user account, and then creates their home folder on a networked machine. I.E: \SERVER\DIR\HOMEDIR.
I have the code working marvelously, except when it comes to making their home directory. It creates the folder, yet it gets and access denied error when it comes to the permissions change. I even have another code that will move the folder and its contents from one directory to another. I have done everything I can think of, the IUSR_MACHINE account even is a domain administrator.
The code is below. Does anyone have any suggestions? Any help would be greately appreciated!
The strHomeFolder is of the form: \SERVER\DIR\DIR with two backslashes at the beginning. I have also tried this on the local server with a local path (C:\DIR\DIR) but that did not work either, same access denied.
Thank you,
Levi
Sub HomeDir()
%>
<br/>
Inside of Homedir()<br/>
<%
strHomeFolder = strHome & strUser
Set objFSO = server.CreateObject("Scripting.FileSystemObject")
Set objShell = server.CreateObject("Wscript.Shell")
If strHomeFolder <> "" Then
If Not objFSO.FolderExists(strHomeFolder) Then
On Error Resume Next
objFSO.CreateFolder strHomeFolder
If Err.Number <> 0 Then
'On Error GoTo 0
'Wscript.Echo "Cannot create: " & strHomeFolder
End If
'On Error GoTo 0
End If
On Error Resume Next
If objFSO.FolderExists(strHomeFolder) Then
%>
<br/>
folder exists<br/>
strHomeFolder = <%=strHomeFolder%><br/>
strUser = <%=strUser%><br/>
<%
'Assign user permission to home folder.
cmdtxt = "%COMSPEC% /c Echo Y| cacls " & strHomeFolder & " /t /c /g Administrators:F " & "SYSTEM:F engineering2\" & strUser & ":F"
intRunError = 25
intRunError = objShell.run(cmdtxt, 2, True)
%>
<br/>
intRunError = <%=intRunError%><br/>
<%
If intRunError <> 0 Then
%>
<br/>
Calcs is balking.......intRunError = <%=intRunError%><br/>
<%
'Wscript.Echo "Error assigning permissions for user " _
'& strUser & " to home folder " & strHomeFolder
End If
End If
End If
Set objFSO = Nothing
Set ob开发者_JAVA技巧jShell = Nothing
End Sub
have you given the DIR folder read/write access? this needs to be done on local and the server. Have you checked that permission?
Caio
精彩评论