Verwijderd schreef op 29 maart 2004 @ 15:21:
Als het even kan wil ik dit dus versnellen. Kan dit ook sneller, bijvoorbeeld door middel van scripts? Het mooiste zou zijn om dit webbased te kunnen doen, dus inloggen op een beveiligde pagina waar je dus een nieuwe website kunt aanmaken. Alleen de meest noodzakelijke zaken opgeven (domeinnaam, default pagina etc.) en voor de rest wordt alles geregeld door een script.
Kan dit zoals ik het voor ogen heb? Hoe doen concullega's dit, icm. Windows en IIS?
Dit is eind 1999 m'n afstudeeropdracht geweest bij een grote hostingprovider. Destijds is het gemaakt voor Windows NT, later is het concept (door anderen) overgezet naar Windows 2000 en wordt vermoedelijk nog steeds zo gebruikt.
Aangezien het stageverslag openbaar is en een andere zeer grote provider
(via een ex-collega) de hele boel ook 'gebruikt' heeft om in haar eigen hosting
systeem in te zetten meen ik dat ik de zooi nu wel kan posten. Ik ga de namen van beide providers niet noemen, maar beide gebruiken dit concept om tientallen zo niet honderden websites te hosten.
Hier een klein voorbeeldje, als je het hele verhaal wil hebben zul je me
even moeten mailen, dan stuur ik je de boel toe.. Niet alle scripts zijn
compleet c.q. goed getest, ik ben destijds niet zover gekomen om de
boel in productie te krijgen, de boel is dus niet helemaal af. De meeste
code is overigens gewoon aangepaste samplecode van verschillende
bronnen (coding is bepaald niet mijn sterkste kant).
Anyway, een stukje voorbeeld om een site aan te maken in
vbscript, vooral gebruik makend van de metabase:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
| '=======================================
' Version: 1.01 (19991215) - Added file and sharecreation
' 1.00 (19991208)
' Assumptions: Domain. Server, Groups, homdirdrive
' (if the physical homedir exists, we do not create the share)
' Inputs: Full_Name, Username, password, luserdescription
' Returns: Fully created user account with existing homedir and share
' in the form of \\servername\description$
' Modules: None this uses ADSI 2.5(Active Directory
' Services Interface to manipulate the
' user entries
' WARNING: Only runs on NT4 (not 2000)
' =======================================
'
'
' usage: vmaakuser.vbs username password "full name" www.domainname.ext
'
option explicit
dim sDomain ' Domain
dim sServer ' Server where home directory is created
dim sUserId ' New Userid
dim sFullName ' Full Name
dim sDescription ' User's Description
dim sPassword ' Password
dim aGroups ' Groups this User is a member of
dim oDomain ' Domain where object is created
dim oUser ' User object
dim oGroup
dim sGroup
dim sHomePath ' Hard place where the homedirs go.. (H:\HOME\)
Dim oArgs
Set oArgs = WScript.Arguments
If oArgs(3) = "" then
Wscript.Echo " "
Wscript.Echo "Usage: vmaakuser.vbs username password 'full name' www.domain.ext"
Wscript.Echo " "
Wscript.Echo "Get a Clue (tm)"
Wscript.Echo " "
Wscript.Quit
End If
'Whoo, fixed values..
'
sDomain="DOMEIN" ' Domain where user id created
sServer="SERVERNAME" ' Server containing home share
sUserid=oArgs(0)
sFullName=oArgs(2)
sDescription=oArgs(3)
sPassword=oArgs(1) ' We fetch the velly secreeet elite password from the command line
aGroups=array("Users","Hosting") ' Groups this user should be part of
sHomePath="H:\HOME\"
' We get the domain
‘
set oDomain = GetObject("WinNT://" + sDomain)
set oUser = oDomain.Create("user",sUserid)
oUser.SetInfo ' ADSI creates some useful defaults, let's do that 1st uh..
oUser.FullName = sFullName
oUser.Description = sDescription
oUser.put "HomeDirDrive","D:" ' Whee.. this is very fixed
' Set the (hidden) homedire share with the name www.sitename.ext
oUser.HomeDirectory = "\\" + sServer + "\" + sDescription + "$"
' $ means a hidden share.. Kinda harsh to have 1000 shares in your network
' neighborhood. A little security trough obscurity also heheh
oUser.SetInfo ' changes are not applied until we do setinfo
' Set the password
oUser.setPassword(sPassword)
' Set the group membership
for each sGroup in aGroups
set oGroup = GetObject("WinNT://" + sDomain + "/" + sGroup)
oGroup.add(oUser.ADSPath)
next
' And let's create the homedir with the name h:\home\desciption and share
' it as \\server\description$
' (But only if the directory doesn't exist already, we are kind enough
' to have more users with the same homedir, since that's the same site)
'
Dim sFolderPath
Dim filesys
Dim tExists
Dim oLANMAN
Dim oShare
sFolderPath = "\\" + sServer + "\" + sDescription 'doh, must be the homedir
Set filesys = Wscript.CreateObject("Scripting.FileSystemObject")
If filesys.FolderExists(sFolderPath) Then
Wscript.Echo "Homedir (" & _
sFolderPath & ") alreadyexists. Assuming the share is also availlable."
Else
Wscript.Echo "Creating the homedir (" & _
sFolderPath & ")."
'Create the folder
filesys.CreateFolder sFolderPath
If Err.Number = 0 Then
Wscript.Echo "Homedir created successfully. Sharing it.."
' Create hidden share on the sServer (=schiphol for now)
set oLANMAN = GetObject ("WINNT://"+ sDomain + sServer + "/lanmanserver")
set oShare = oLANMAN.Create("fileshare", sDescription + "$")
oShare.Path = sHomePath + sDescription ' h:\home\ + desc
oShare.Description = sDescription ' Aren't we informative..
oShare.SetInfo ' Put it into action
Else
Wscript.Echo "Homedir creation NOT SUCCESSFUL! (Thus no share)"
End If
End If
' Change the NTFS rights on the created dir to +full_control for lusername
' (and keep the existing rights!)
'
' BTW: read/execute rights for IUSR_SERVERNAME are inherited from the above dir,
' just like Full Control for Administrator
'
Dim shell
Set shell = Wscript.CreateObject("Wscript.Shell")
shell.Run('cscript //NoLogo //b cacls.exe ' + sHomePath + sDescription + ' /T /E /G ' + sUserid + ':F')
WScript.echo "Created user " + sUserid + " in domain " + sDomain + " with password " + sPassword
WScript.quit
' The End.. |
Ik hoop dat het je een beetje inzicht geeft in wat mogelijk is, je kunt dus in principe compleet gescript sites aanmaken, aanpassen en verwijderen. Houdt er rekening mee dat bovenstaande code alweer meer dan 4 jaar oud is, dus
inmiddels is er vast meer mogelijk en vrij beschikbaar.