ASP creates users, directories, and sites

zhaozj2021-02-16  51

This lecture will be used to ADSI, an active directory service interface. You can find some relevant information until 15seconds.com.

1. Create the user below to create a user USER1 on the stand-alone server White, initial password user1, use adsi.dim username, userpassdim odomain, OUSERUSERNAME = "User1" Userpass = "user1" set odomain = getObject ("Winnt: / / white ") set Ouser = odomain.create (" User ", username) THENOUSER.SETINFOOUSER.SETPASSWORD UserPassouser.setinfoelseWscript.echo creates User" & UserName & "Error!" end ifset Ouser = NothingSet odomain = Nothing

2. Create a directory using the FileSystemObject to create the directory: Dim FsObjectDim tmpFolderSet FsObject = WScript.CreateObject ( "Scripting.FileSystemObject") tmpFolder = "D: / userdate / user1" If Not FsObject.FolderExists (tmpFolder) ThenFsObject.CreateFolder (tmpFolder) If Err .Number <> 0 damcript.echo "Create Directory" & TMPFolder & "Failed!" End ifnd ifnd Ifnd IF Noted before creating a directory, check if the directory exists, if existent, no creation.

3. Creating a Site This subroutine is responsible for creating a WWW site, the meaning of each parameter is: Site IP address, site root directory, site description, host name, port number, computer name (one moved to localhost), is it immediately started, The account of the account used when anonymous access, an anonymous access to the password of the log file. The function returns the serial number of the site in IIS (in IIS, all the sites are numbered in the IIS. One call Example: SiteId = AstcreateWebsite ("10.1.3.122", "D: / UserData / User1", "WWW_USER1", "80", "Localhost", True, "IUSR_USER1", "8IUI% #", "D : / Logfiles ")

Function ASTCreateWebSite (IPAddress, RootDirectory, ServerComment, HostName, PortNum, Computer, Start, AnonymousUserName, AnonymousUserPass, LogFileDirectory) Dim w3svc, WebServer, NewWebServer, NewDirDim Bindings, BindingString, NewBindings, Index, SiteObj, bDoneOn Error Resume NextErr.ClearSet w3svc = GetObject ("IIS: //" & Computer & "/ W3SVC") if err.Number <> 0 damcript.echo "Unable to open:" & "IIS: //" & Computer & "/ W3SVC" & VBCRLF & "program exit "WScript.Quit (1) End IfBindingString = IpAddress &":. "& PortNum &": "& HostNameFor Each WebServer in w3svcIf WebServer.Class =" IIsWebServer "ThenBindings = WebServer.ServerBindingsIf BindingString = Bindings (0) ThenWScript.Echo "IP address conflict:" & ipaddress & ", please detect the IP address!" & Vbrlf & "cancels creates this site." EXIT functionend ifnd ifnext

Index = 1bdone = false

While (Not bDone) Err.ClearSet SiteObj = GetObject ( "IIS: //" & Computer & "/ w3svc /" & Index) If (Err.Number = 0) ThenIndex = Index 1ElseErr.ClearSet NewWebServer = w3svc.Create ( "IIsWebServer ", Index) if (err.Number <> 0) ThenIndex = index 1elseerr.clearset siteobj = getObject (" IIS: // "& computer &" / w3svc / "& index) ife = IFEX 1END IFEND IFEND IF

If (index> 10000) thenwscript.echo "does not create a site, the serial number of the site being created is:" & index & "." & VBCRLF & "Cancel Create this site." EXIT Functionend ifwend

NewBindings = Array (0) NewBindings (0) = BindingStringNewWebServer.ServerBindings = NewBindingsNewWebServer.ServerComment = ServerCommentNewWebServer.AnonymousUserName = AnonymousUserNameNewWebServer.AnonymousUserPass = AnonymousUserPassNewWebServer.KeyType = "IIsWebServer" NewWebServer.FrontPageWeb = TrueNewWebServer.EnableDefaultDoc = TrueNewWebServer.DefaultDoc = "Default.htm , Default.asp, Index.htm, Index.asp "NewWebServer.LogFileDirectory = LogFileDirectoryNewWebServer.SetInfoSet NewDir = NewWebServer.Create (" IIsWebVirtualDir "," ROOT ") NewDir.Path = RootDirectoryNewDir.AccessRead = trueNewDir.AppFriendlyName =" application " & ServerCommentNewDir.AppCreate TrueNewDir.AccessScript = TrueErr.ClearNewDir.SetInfoIf (Err.Number = 0) ThenElseWScript.Echo "An error occurred while the home directory is created." End IfIf Start = True ThenErr.ClearSet NewWebServer = GetObject ( "IIS: //" & Computer & "/ W3SVC /" & INDEX) NewWebserver.Startif Err.Number <> 0 thenwscript.echo "When the site is started!" Err.cleareLseEnd IFEnd if AstCreateWebsite = Indexend Function

The following function creates an FTP site: Function ASTCreateFtpSite (IPAddress, RootDirectory, ServerComment, HostName, PortNum, Computer, Start, LogFileDirectory) Dim MSFTPSVC, FtpServer, NewFtpServer, NewDirDim Bindings, BindingString, NewBindings, Index, SiteObj, bDoneOn Error Resume NextErr.ClearSet MSFTPSVC = GetObject ("IIS: //") if err.Number <> 0 damcript.echo "Unable to open:" & "IIS: //" & "&" / msftpsvc "& vbcrlf &" The program will exit. "WScript.quit (1) end if

BindingString = IpAddress & ":" & PortNum & ":" & HostNameFor Each FtpServer in MSFTPSVCIf FtpServer.Class = "IIsFtpServer" ThenBindings = FtpServer.ServerBindingsIf BindingString = Bindings (0) ThenWScript.Echo "IP address conflict:" & IpAddress & " Please detect the IP address! "& Vbcrf &" Cancel Cancel this site. "EXIT functionend ifnd ifnextIndex = 1bdone = false

While (Not bDone) Err.ClearSet SiteObj = GetObject ( "IIS: //" & Computer & "/ MSFTPSVC /" & Index) If (Err.Number = 0) ThenIndex = Index 1ElseErr.ClearSet NewFtpServer = MSFTPSVC.Create ( "IIsFtpServer ", Index) if (err.number <> 0) ThenIndex = index 1elseerr.clearset siteobj = getObject (" IIS: // "& computer &" / msftpsvc / "& index) if (Err.Number = 0) THENBDONE = TrueelseIndex = IFEX 1END IFEND IFEND IF

If (index> 10000) thenwscript.echo "does not create a site, the serial number of the site being created is:" & index & "." & VBCRLF & "Cancel Create this site." EXIT Functionend ifwend

NewBindings = Array (0) NewBindings (0) = BindingStringNewFtpServer.ServerBindings = NewBindingsNewFtpServer.ServerComment = ServerCommentNewFtpServer.AllowAnonymous = FalseNewFtpServer.AccessWrite = TrueNewFtpServer.AccessRead = TrueNewFtpServer.DontLog = FalseNewFtpServer.LogFileDirectory = LogFileDirectoryNewFtpServer.SetInfo

转载请注明原文地址:https://www.9cbs.com/read-15672.html

New Post(0)