HOWTO: Programmatically Gain Anonymous Access to Public Folders

Last reviewed: January 16, 1998
Article ID: Q179332
The information in this article applies to:
  • Collaboration Data Objects (CDO), version 1.2

SUMMARY

This article describes how to programmatically gain anonymous access to a public folder on your Microsoft Exchange Server from an Active Server Page (ASP) page.

Please note that you can gain non-programmatic anonymous access to any public folder on the Exchange Server using the built in Hypertext Transfer Protocol (HTTP) supported by Exchange Server.

MORE INFORMATION

To gain anonymous programmatic access to an Exchange Public folder from an ASP page, you need to setup several components of Windows NT, Exchange and Internet Information Server (IIS) correctly. This example creates a new user on the domain using "User Manager for Domains," the "Microsoft Exchange Administrator," and the "Internet Service Manager."

User Manager for Domains

  1. Open the User Manager and from the User menu, choose New User. Set the following properties:

          Username:          AnonUser
          Full Name:         Anonymous User.
          Description:       For anonymous Web access to Public Folders
          Password:          Fill in an appropriate password.
          Confirm Password:  Repeat password.
    
          User Must Change Password at Next Logon:     OFF
          User Cannot Change Password:                 ON*
          Password Never Expires:                      ON*
          Account Disabled:                            OFF
    
       NOTE: You may set these values to OFF. If you set these values OFF, you
       need to change the password in the IIS Manager as well as in the
       account.
    
    
          Groups:       Member of:  Domain Users
                                    Domain Guests
    
          Profiles:     User Profiles or Home Directory settings are not
                        required.
    
          Hours:        No settings are required.
    
          Logon to:     Set as appropriate.
    
          Account:      Account Expires: Never
                        Account Type:    Global Account for regular user
                                         accounts in the domain.
    
          Dialin:       "Grant dialin permissions to user":  OFF
                        "Call Back":  No Call Back.
    
    
    

  2. Click Add. If you have configured your server to automatically create an Exchange account the Exchange User Properties dialog box appears. If the dialog box does not appear, you need to open the "Microsoft Exchange Administrator" and create a new mailbox.

  3. Before or after creating the new mailbox, click User Rights from the Policies menu in the User Manager. Click Log on Locally from the drop- down menu on the right. Click Add and add the AnonUser. The user you created now has rights to log on locally to the IIS server.

Microsoft Exchange Administrator

  1. Fill in the following properties on the General Tab:

          First Name:             Anonymous
          Last Name:              User
          Display:                Anonymous User
          Alias:                  AnonUser
          Primary NT Account:     DOMAIN\AnonUser
    
    

  2. You do not need to set any other properties. Click OK.

Microsoft Internet Service Manager

  1. Select the server you want anonymous users to access your Web from and set the following properties:

          Anonymous Logon
          ---------------
    

            UserName:     AnonUser
            Password:     Fill in the password you created while creating the
                          Anonymous User account. Confirm the password in the
                          appropriate dialog box.
    
          Password Authentication
          -----------------------
    
            Allow Anonymous:                   ON
            Basic (Clear Text):                As Desired
            Windows NT Challenge Response:     As Desired*
            * You may want to turn Windows NT Challenge Response ON so
            you can author to the Web from another computer.
    
    

  2. Click OK and confirm the password.

Active Server Page (ASP)

Now your system is configured to allow an anonymous user to gain access to the Public Folders on your Exchange Server. Your ASP code must reflect the settings you have created. When logging into the session your code should log you onto the mailbox of "AnonUser" as demonstrated in the following code. This sample code shows how to gain access to the Internet Newsgroups folder.

Here is the sample code:

   <%@ LANGUAGE="VBSCRIPT" %>

   <HTML>
   <HEAD>
   <META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
   <META HTTP-EQUIV="Content-Type" content="text/html;charset=iso-8859-1">
   <TITLE>Document Title</TITLE>
   </HEAD>
   <BODY>

   <%
   CONST strServer     = "MyExchangeServer"
   CONST strMailbox    = "AnonUser"
   Dim objSession
   Dim objMessages
   Dim objOneMessage
   Dim objInfoStores
   Dim objInfoStore
   Dim objTopFolder
   Dim objFolders
   Dim objSubFolder
   Dim objTargetFolder
   Dim strProfileInfo
   Dim i
   Dim bstrPublicRootID

   strProfileInfo = strServer & vblf & strMailbox
   Set objSession = Server.CreateObject("MAPI.Session")
   objSession.Logon , , , False, , True, strProfileInfo
   Set objInfoStores = objSession.InfoStores
   For i = 1 To objInfoStores.Count
      If objInfoStores.Item(i)= "Public Folders" Then
         Set objInfoStore=objInfoStores.Item(i)
         Exit For
      End If
   Next

   bstrPublicRootID = objInfoStore.Fields.Item( &H66310102 ).Value
   Set objTopFolder = objSession.GetFolder(bstrPublicRootID, _
                      objInfoStore.ID)
   Set objFolders = objTopFolder.Folders
   Set objFolder = objFolders.GetFirst()
    Do Until objFolder.Name = "Internet Newsgroups"
      Set objFolder=objFolders.GetNext()
   Loop
   Set objMessages = objFolder.Messages
   For Each objOneMessage in objMessages
      Response.Write("objOneMessage.Subject = " & _
                     objOneMessage.Subject & "<br>")
      Response.Write("objOneMessage.Text = " & _
                     objOneMessage.Text & "<br>")
   Next
    objSession.Logoff
   Set objOneMessage = Nothing
   Set objMessages = Nothing
   Set objFolder = Nothing
   Set objTopFolder = Nothing
   Set objSession = Nothing
   %>
   </BODY>
   </HTML>

REFERENCES

For more information please see "Implementing a Secure Site with ASP," located at:

   http://www.microsoft.com/isn/techcenter/security.htm

For additional information on designating Public Folders for Web access, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q168661
   TITLE     : PRB: Accessing Public Folders Via a Web Browser Causes Error

Keywords          : cdo
Version           : WINDOWS:1.2
Platform          : WINDOWS
Issue type        : kbhowto


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 16, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.