Create Virtual Directory
Entry In IIS
As per the name, it's easy to guess what this project is all about, creating a virtual directory in the default web site (80). The program uses the IIS Administration SDK, which has the Active Directory Service Interfaces (ADSI) that helps VC++ to access the required functions and interfaces.
I started looking on the net for similar programs that uses ADSI with VC++, but was not able to find one, so thought of creating one.
Using the code
To access the ADSI functions, we need to have the following header files.
const LPWSTR adsPATH = L"IIS://localhost/w3svc/1/Root";
IDispatch *pDisp = NULL; IADs* iAds = NULL; IADsContainer* iContainer = NULL; IISApp *pApp = NULL;
Access the ADSI object
Creating a virtual directory
hr = iContainer->Create(L"IIsWebVirtualDir", cAppName, &pDisp);
Creating the application with the use of QueryInterface
hr = iAds->QueryInterface( IID_IISApp, (void **)&pApp );
Accessing the virtual directory property using the iAds interface
hr = iAds->Put(L"AccessRead",CComVariant(VARIANT_TRUE));
hr = iAds->Put(L"AccessWrite",CComVariant(VARIANT_TRUE));
hr = iAds->Put(L"AccessScript",CComVariant(VARIANT_TRUE));
hr = iAds->Put(L"AppIsolated",CComVariant(1));
hr = iAds->Put(L"EnableDirBrowsing",CComVariant(VARIANT_TRUE));
hr = iAds->Put(L"AppFriendlyName",CComVariant(cAppName));
hr = iAds->Put(L"Path",CComVariant(clPath));
Update the changes to the ASDI objects
hr = iAds->SetInfo();
You might end up in getting a link error. To solve this,s the following libraries need to be included:
The currently supported languages are: C++.
Points of interest
While trying out lots of options, I had to interpret .NET code and transform it in to VC++, and one thing I found is whatever the language is, you just need a vision to make it work.