I needed to provide access to items from selected folders in a SharePoint Services 2.0 Document Library. I couldn't give read access to the entire library (your only option in WSS 2.0) because allowing them to browse the entire folder tree was not an option.
So I wrestled with options of opening the docs from an anonymous web page passing a valid WSS user's credentials, investigated the SPS DWS web service (which I used in the past for creating document folder trees), and wasted an hour or so with the Microsoft.Sharepoint libraries, considering a strategy where I could duplicate folder contents to another document library or something. (Does anyone do anything useful with those libraries outside of building webparts in .NET 1.1? Does anyone else find the API difficult to understand?)
So I decided to screw the whole WSS approach to retrieving documents and went straight to SQL. What I did, essentially, was to retrieve the binary directly from the WSS SQL database using the item's GUID. Works like a charm, document library is secure, and the documents open in their native applications: Excel, Work, TextPad, Acrobat, etc.
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
string guid = Request.QueryString["guid"].ToString();
SqlDataReader dr = DataSharepointHelper.GetDocDescByGuid(guid);
dr.Read();
Response.OutputStream.Write((Byte[]) dr["Content"],0, int.Parse(dr["Size"].ToString()));
Response.AddHeader("Content-Disposition", "attachment;filename=" + dr["leafname"].ToString());
}
}