To work around this problem, create an .htm file that does the following:
- Accepts the user name and the password that are used to access the data on the security-enhanced database
- Writes the user name and the password to a cookie
- Navigates to the data access page
The data access page is modified to include a script that sets the
UseRemoteProvider property to
True. The script also modifies the
ConnectionString property of the data access page to include the following:
- The Jet OLEDB:System Database parameter as an extended property
- The user name and the password that are read from the cookie
To create an .htm file, follow these steps.
Note Make sure that the data access page is stored in a folder that is created in the home directory of the default Web site on the IIS server. For example, you may use the following path:
<InstallationDrive>:\inetpub\wwwroot\databases
- Create an .htm file that contains HTML code that is similar to the following.
Note In the following code, replace <ServerName> with the name of the server where the data access page is deployed from. Replace <VirtualDirectory> with the name of the virtual directory on the IIS server where the data access page is deployed from. Replace <DataAccessPage> with the name of the data access page. For example, you may replace "<ServerName>/<VirtualDirectory>/<DataAccessPage>" with "testserver/databases/SecureDAP.htm." <HTML>
<HEAD>
<TITLE>Authenticate User</TITLE>
<SCRIPT language="VBScript">
Sub writeCookie(strVariableName, varVariableValue)
Document.Cookie = strVariableName & "=" & varVariableValue
End Sub
Sub openDAP()
Dim varUserID
Dim varPWD
varUserID = document.all.txtUserID.value
varPWD = document.all.txtPWD.value
writeCookie "pUserID", varUserID
writeCookie "pPWD", varPWD
'Change "ServerName" to the name of your server.
window.navigate("http://<ServerName>/<VirtualDirectory>/<DataAccessPage>")
End Sub
</SCRIPT>
</HEAD>
<BODY>
<FORM id="form1">
<TABLE>
<TR>
<TD>User Name:</TD>
<TD><input type="text" name="txtUserID" size="20"></TD>
</TR>
<TR>
<TD>Password:</TD>
<TD><input type="password" name="txtPWD" size="20"></TD>
</TR>
</TABLE>
<P><input type="button" value="Open DAP"
name="B2" onClick="openDAP()"></P>
</FORM>
</BODY>
</HTML>
- Save the .htm file in the folder where the data access page is stored. Name the file Authenticate.htm.
- Open the data access page in Access.
- On the View menu, click HTML Source.
-
In Microsoft Script Editor, add the following code in the HEAD tag.
Note Replace <FullPathToDatabaseFile> with the full path of the security-enhanced database file. For example, you may use the following path:
<InstallationDrive>:\inetpub\wwwroot\databases\DatabaseForDAP.mdb
Note Replace <FullPathToWorkgroupInformationFile> with the full path of the workgroup information file. For example, you may use the following path:
<InstallationDrive>:\inetpub\wwwroot\databases\System.mdw<SCRIPT language=VBScript>
Function readCookie(strVariableName)
Dim intLocation
Dim intNameLength
Dim intValueLength
Dim intNextSemicolon
Dim strTemp
' Calculate the length and the location of the variable name.
intNameLength = Len(strVariableName)
intLocation = Instr(Document.Cookie, strVariableName)
strTemp = Right(Document.Cookie, Len(Document.Cookie) - intLocation + 1)
' Find the position of the next semicolon.
intNextSemicolon = Instr(strTemp, ";")
' If not found, assume that you are at the end.
If intNextSemicolon = 0 Then
intNextSemicolon = Len(strTemp) + 1
End If
intValueLength = intNextSemicolon - intNameLength - 2
If intValueLength=-1 then
readCookie=""
Else
readCookie = Mid(strTemp, intNameLength + 2, intValueLength)
End If
End Function
'You must replace this string if the data source is an SQL Server data source.
Document.MSODSC.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;" & _
";Data Source=<FullPathToDatabaseFile>" & _
";User ID=" & readCookie("pUserID") & _
";Password=" & readCookie("pPWD") & _
";Extended Properties=Jet OLEDB:System database=<FullPathToWorkgroupInformationFile>" & _
";Mode=Share Deny None" & _
";Persist Security Info=False"
Document.MSODSC.UseRemoteProvider=True
</SCRIPT>
Note If the data access page contains controls that are bound to an SQL Server data source, you must use a connection string that is similar to the following:Document.MSODSC.ConnectionString="Provider=SQLOLEDB.1" & _
";User ID=" & readCookie("pUserID") & _
";Password=" & readCookie("pPWD") & _
";Initial Catalog=<DatabaseName>" & _
";Data Source=<ServerName>" & _
";Persist Security Info=False"
Document.MSODSC.UseRemoteProvider=True
Note Replace <DatabaseName> with the name of the appropriate database. For example, you may use the Northwind.mdb sample database. - Use a client browser, such as Microsoft Internet Explorer, to open the Authenticate.htm file. Use a URL that is similar to the following:
http://Testserver/Databases/Authenticate.htm - In the Authenticate User Web page, type a valid user name in the User Name box, type a valid password in the Password box, and then click Open DAP.
You notice that the data access page
appears correctly in the client browser.