home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1998 April B
/
Pcwk4b98.iso
/
ie401gb
/
IEAK4.CAB
/
autocfg2.asp
< prev
next >
Wrap
Text File
|
1997-10-08
|
9KB
|
282 lines
<%
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% FILE: AUTOCFG.ASP
'% DATE: 08/23/97
'% AUTHOR: Aaron Barth (MS)
'% DESCRIPTION: Customizable ASP script to perform the
'% IEAK AutoConfig
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% Set the DEBUGFLAG Paramter to
'% TRUE to DEBUG this File. By Default this Parameter
'% is FALSE
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DEBUGFLAG = FALSE
if DEBUGFLAG =TRUE then
Response.Write "<FONT COLOR=RED> <B>DEBUG OUTPUT:</B></FONT><BR>"
end if
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% Set AuthUserandDomain to the Authenticated user's
'% DOMAIN\username
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if Request.Cookies("IEAKUser") = "" then
AuthUserandDomain="DOMAIN\guest"
else
AuthUserandDomain = Request.Cookies("IEAKUser")
end if
if DEBUGFLAG =TRUE then
Response.Write AuthUserandDomain & "<BR>"
Response.write "Authentication Method: " & Request.ServerVariables("AUTH_TYPE") & "<BR>"
end if
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% Flip the "\" to a "/" so that the ADSI Command
'% GetObject:// can use it
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
AuthUserandDomain = Replace(AuthUserandDomain, "\", "/")
if DEBUGFLAG = TRUE then
Response.Write AuthUserandDomain + "<BR>"
end if
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% Because GetUser() is a destructive function, copy
'% the value of the the DOMAIN/username into UserandDomain
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UserandDomain = AuthUserandDomain
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% User the GetUser function to strip off the Domain
'% Name from UserandDomain and put it in AuthUser for
'% later
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
AuthUser = GetUser(UserandDomain)
if DEBUGFLAG = TRUE then
Response.Write AuthUser + "<BR>"
end if
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% Use the GetObject (ADSI) to obtain the user object
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Set User=GetObject("WinNT://" & AuthUserandDomain)
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% Loop through all User.Groups looking for the "IE_"
'& prefix to a group name
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
For Each Group in User.Groups
if Left(Group.Name, 3) = "IE_" then
IsGroupMember = TRUE
IEGroupName = Group.Name
end if
Next
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% If user is a Member of IE_ [groupname] then
'% Build a custom INSFile
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if IsGroupMember = TRUE then
if DEBUGFLAG = TRUE then
Response.write IEGroupName & "<BR>"
end if
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% Create the Conn Object and open it
'% with the supplied parameters
'% from the global.asa
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Set Conn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.RecordSet")
Conn.Open Session("DataConn_ConnectionString"), Session("DataConn_RuntimeUserName"), Session("DataConn_RuntimePassword")
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% Create the SQL Statement to Select
'% GroupName and INSFile from IEgroup
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
sql="SELECT * FROM IEGroup"
sql = sql & " WHERE GroupName"
sql = sql & " LIKE '" & IEGroupName & "'"
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% When DEBUGFLAGE = TRUE.. Echo the SQL Statement
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if DEBUGFLAG = TRUE then
Response.Write "<B><FONT SIZE=2 COLOR=BLUE>SQL STATEMENT: </B>" & sql & "<HR>"
end if
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% Open the RecordSet (RS) and pass it
'% the connection (conn) and the SQL Statement (sql)
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RS.Open sql, Conn, 1
RS.MoveFirst
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% If the SQL statement does not return
'% any matches, write out a nice error statment
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if RS.EOF then
Response.Write "No Configuration defined for " & IEGroupName & "<BR>"
else
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% Retrieve the whole INS file from
'% the DB and put it in TheINSFile
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TheINSFile = RS("INSFile")
TheINSFileName = IEGroupName & ".INS"
if DEBUGFLAG = TRUE then
Response.Write "<HR>" & TheINSFile & "<HR>"
Response.Write "<HR>" & TheINSFileName & "<HR>"
end if
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% Write information out to a text file
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Set fs = CreateObject("Scripting.FileSystemObject")
filepath = server.mappath(TheINSFileName)
Set a = fs.CreateTextFile(filepath, True)
a.WriteLine(TheINSFile)
a.close
end if
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% Close the RecordSet (RS)
'% and the Connection (Conn)
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RS.Close
Conn.Close
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% If DEBUGFLAG <> TRUE, send the
'% file to the browser
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if DEBUGFLAG = TRUE then
Response.Write "If you weren't debugging this File you would be redirected to " & TheINSFileName
else
Response.redirect TheINSFileName
end if
else
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% Retrieve the Default INS File
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if DEBUGFLAG = TRUE then
Response.write "Default User <BR>"
end if
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% Create the Conn Object and open it
'% with the supplied parameters
'% from the global.asa
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Set Conn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.RecordSet")
Conn.Open Session("DataConn_ConnectionString"), Session("DataConn_RuntimeUserName"), Session("DataConn_RuntimePassword")
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% Create the SQL Statement to Select
'% GroupName and INSFile from IEgroup
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
sql="SELECT * FROM IEGroup"
sql = sql & " WHERE GroupName"
sql = sql & " LIKE 'Default'"
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% When DEBUGFLAGE = TRUE.. Echo the SQL Statement
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if DEBUGFLAG = TRUE then
Response.Write "<B><FONT SIZE=2 COLOR=BLUE>SQL STATEMENT: </B>" & sql & "<HR>"
end if
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% Open the RecordSet (RS) and pass it
'% the connection (conn) and the SQL Statement (sql)
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RS.Open sql, Conn, 1
RS.MoveFirst
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% If the SQL statement does not return
'% any matches, write out a nice error statment
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if RS.EOF then
Response.Write "No Configuration defined for " & IEGroupName & "<BR>"
else
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% Retrieve the whole INS file from
'% the DB and put it in TheINSFile
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TheINSFile = RS("INSFile")
TheINSFileName = "Default.INS"
if DEBUGFLAG = TRUE then
Response.Write "<HR>" & TheINSFile & "<HR>"
Response.Write "<HR>" & TheINSFileName & "<HR>"
end if
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% Write information out to a text file
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Set fs = CreateObject("Scripting.FileSystemObject")
filepath = server.mappath(TheINSFileName)
Set a = fs.CreateTextFile(filepath, True)
a.WriteLine(TheINSFile)
a.close
end if
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% Close the RecordSet (RS)
'% and the Connection (Conn)
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RS.Close
Conn.Close
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'% If DEBUGFLAG <> TRUE, send the
'% file to the browser
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if DEBUGFLAG = TRUE then
Response.Write "If you weren't debugging this File you would be redirected to " & TheINSFileName
else
Response.redirect TheINSFileName
end if
end if
Function GetUser(username)
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'Syntax: username = DOMAIN/username
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' this is a destructive function, modifying the
' passed in string
' trim leading slashes
While Mid(username, 1, 1) = "/"
username = Mid(username, 2)
Wend
' find next slash
pos = InStr(1, username, "/")
If pos = 0 Then
' return the remaining string and null it out
GetUser = username
username = ""
Else
' extract next user and chop username
GetUserFromString = Mid(username, 1, pos - 1)
username = Mid(username, pos + 1)
GetUser = username
End If
End Function
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%>