Microsoft KB Archive/277905

= XCCC: How to Create an HTTP Virtual Directory on an Exchange 2000 Server for a Public Folder =

Article ID: 277905

Article Last Modified on 2/27/2007

-

APPLIES TO


 * Microsoft Exchange 2000 Server Standard Edition

-



This article was previously published under Q277905



SUMMARY
This article contains sample code that shows how to use ADSI to create an HTTP virtual directory object on Exchange 2000 server with Microsoft Visual Basic.



MORE INFORMATION
You can run this sample code in Microsoft Visual Basic 6.0 or Microsoft Visual Basic Scripting Edition. You must first add the Active DS Type Library object (Winnt\System32\Activeds.tlb, available on all Microsoft Windows 2000 domain controllers), and the Microsoft CDO for Exchange Management Library object (Cdoexm.dll) to the References option of the Visual Basic project settings.

Use the following code to create the HTTP virtual directory: ' StrFolderName: The folder path that you want to publish as the virtual directory. Use the following format: &quot;\&quot; ' strComputerName: The computer name of your Exchange 2000 server where you set up this virtual directory. Function CreateWeb(strFolderName as String, strComputerName as String)as Boolean

Dim iServer        As New CDOEXM.ExchangeServer Dim strFHName      As String Dim NewWeb         As IADsContainer Dim ADCont         As IADsContainer

Set iServer = CreateObject(&quot;CDOEXM.ExchangeServer&quot;)

Result = True

iServer.DataSource.Open strComputerName Set ADCont = GetObject(&quot;LDAP://&quot; & iServer.DirectoryServer & &quot;/CN=1,CN=HTTP,CN=Protocols,&quot;_   & Mid(iServer.DataSource.SourceURL, InStr(1, iServer.DataSource.SourceURL, &quot;cn=&quot;)))

Set NewWeb = ADCont.Create(&quot;msExchProtocolCfgHTTPVirtualDirectory&quot;, &quot;cn=&quot; & strFolderName)

NewWeb.Put &quot;hTTPPubGAL&quot;, CBool(0) NewWeb.Put &quot;anonymousAccount&quot;, &quot;IUSR_&quot; & strComputerName NewWeb.Put &quot;folderPathname&quot;, CStr(strFolderName) ' &quot;msExchAccessFlags&quot; property: contains the virtual directory execute permission: '512 = Execute Permission=Script '516 = Execute Permission=Script&Execute '1=Read, 2=Write, 16=Script Access NewWeb.Put &quot;msExchAccessFlags&quot;, CInt(535) ' &quot;msExchAuthenticationFlags&quot; property: contains the virtual directory authentication settings: '1=Anonymous Access, 2=Basic, 4=NTLM NewWeb.Put &quot;msExchAuthenticationFlags&quot;, CInt(7) NewWeb.Put &quot;msExchBasicAuthenticationDomain&quot;, CStr(strDomainName) NewWeb.Put &quot;msExchDefaultLogonDomain&quot;, CStr(strDomainName) ' &quot;msExchDirBrowseFlags&quot; property: controls the Web directory browse permission of the virtual directory: '1073741854=No Dir Browse, -1073741794=Dir Browse NewWeb.Put &quot;msExchDirBrowseFlags&quot;, -1073741794

'The property specifies the logon method for clear text logons NewWeb.Put &quot;msExchLogonMethod&quot;, CInt(3) NewWeb.Put &quot;msExchServerAutoStart&quot;, CBool(-1) ' &quot;msExchServerRole&quot; property: This virtual directory resides on the front end or back end server: ' 1 = This is a front end server ' 0 = This is a back end server NewWeb.Put &quot;msExchServerRole&quot;, CInt(0) NewWeb.Put &quot;name&quot;, CStr(strFolderName) 'newweb.Put &quot;showInAdvancedViewOnly&quot;, cbool(-1)

On Error Resume Next Err.Clear NewWeb.SetInfo If Err <> 0 Then ' If user exists no need to raise an err If Err.Number <> &H80071392 Then MsgBox CStr(Err.Number) + &quot;) &quot; + Err.Description,, Err.Source         Result = False        End If    End If

Set NewWeb = Nothing Set ADCont = Nothing Set iServer = Nothing

CreateWeb = Result End Function

Additional query words: Virtual directory msExchProtocolCfgHTTPVirtualDirectory

Keywords: kbhowto KB277905

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.