By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,916 Members | 1,336 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,916 IT Pros & Developers. It's quick & easy.

Cannot create a Virtual Directory using System.DirectoryServices on Windows Vista RC1

P: n/a
The following is an extract from a C# console application that creates
a Virtual Directory on IIS 5 or 6.

This code works on XP, Windows 2003 Server, Windows 2000.

It does not work on Windows Vista Release Candidate 1 (IIS 7).

The below line

pcProps[VDPROP_PATH].Value = strPath;

throws the exception "Path not found".

Note that the user running the exe has administrator rights on the
machine.

Also, this may be a related issue:

The Microsoft VB script C:\Inetpub\Adminscripts\mkwebdir.vbs no longer
works on Windows Vista RC1 when logged in as an administrator. The
exact same script and parameters runs on Windows XP.

Interestingly, I have found that other sample code downloaded from the
Internet that creates virtual directories does not work on Vista
either.

I suspect that this is a rights issue, but I do not know how to solve
this.

Thanks for your help.

+++++++++++

Code extract:
DirectoryEntry deRoot = new DirectoryEntry(IIS_DIR);

if (null != deRoot)

try
{
// check to see if this Virtual Directory already exists
m_deVirtualDir = deRoot.Children.Add(m_strVirtualDir,
IIS_SCHEMA_VIRTUAL_DIR);
}
catch
{
try
{
String strDir = IIS_DIR + "/" + m_strVirtualDir;
m_deVirtualDir = new DirectoryEntry(IIS_DIR + "/" +
m_strVirtualDir);
}
catch
{
}
}

if (null != m_deVirtualDir)
{
// commit the changes so far!
deRoot.CommitChanges();
m_deVirtualDir.CommitChanges();

// now we need to set up some properties of the new virtual
// directory
PropertyCollection pcProps = m_deVirtualDir.Properties;
// set the Path to the Virtual Directory
string strPath = m_strIISPath + "\\" + m_strVirtualDir;

// exception generated here
pcProps[VDPROP_PATH].Value = strPath;

etc etc

Oct 5 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Please post Vista related problems to the Vista forums, check following URL
for available NG's and Forums
http://msdn.microsoft.com/windowsvis...y/default.aspx.
Be aware that on Vista, even an administrator runs with reduced privileges
(by default), I suggest you try to strat this with elevated privileges.

Willy.
<fr********@hotmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
| The following is an extract from a C# console application that creates
| a Virtual Directory on IIS 5 or 6.
|
| This code works on XP, Windows 2003 Server, Windows 2000.
|
| It does not work on Windows Vista Release Candidate 1 (IIS 7).
|
| The below line
|
| pcProps[VDPROP_PATH].Value = strPath;
|
| throws the exception "Path not found".
|
| Note that the user running the exe has administrator rights on the
| machine.
|
| Also, this may be a related issue:
|
| The Microsoft VB script C:\Inetpub\Adminscripts\mkwebdir.vbs no longer
| works on Windows Vista RC1 when logged in as an administrator. The
| exact same script and parameters runs on Windows XP.
|
| Interestingly, I have found that other sample code downloaded from the
| Internet that creates virtual directories does not work on Vista
| either.
|
| I suspect that this is a rights issue, but I do not know how to solve
| this.
|
| Thanks for your help.
|
| +++++++++++
|
| Code extract:
| DirectoryEntry deRoot = new DirectoryEntry(IIS_DIR);
|
| if (null != deRoot)
|
| try
| {
| // check to see if this Virtual Directory already exists
| m_deVirtualDir = deRoot.Children.Add(m_strVirtualDir,
| IIS_SCHEMA_VIRTUAL_DIR);
| }
| catch
| {
| try
| {
| String strDir = IIS_DIR + "/" + m_strVirtualDir;
| m_deVirtualDir = new DirectoryEntry(IIS_DIR + "/" +
| m_strVirtualDir);
| }
| catch
| {
| }
| }
|
| if (null != m_deVirtualDir)
| {
| // commit the changes so far!
| deRoot.CommitChanges();
| m_deVirtualDir.CommitChanges();
|
| // now we need to set up some properties of the new virtual
| // directory
| PropertyCollection pcProps = m_deVirtualDir.Properties;
|
|
| // set the Path to the Virtual Directory
| string strPath = m_strIISPath + "\\" + m_strVirtualDir;
|
| // exception generated here
| pcProps[VDPROP_PATH].Value = strPath;
|
| etc etc
|
Oct 5 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.