Windows Service & DirectoryServices & IIS

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tpeczek
    New Member
    • Feb 2008
    • 1

    Windows Service & DirectoryServices & IIS

    Hi

    I'm writing windows service which is suppose to acces IIS metabase using DirectoryServic es. I'm accesing IIS using the code below:

    Code:
    DirectoryEntry iisEntry = new DirectoryEntry(@"IIS://" + _iis + @"/W3SVC", userName + "@" + domain, password, AuthenticationTypes.Secure);
    
    foreach (DirectoryEntry webServerEntry in iisEntry.Children)
    {
            //some code here
    }
    At begining of foreach statement I'm getting "Acces denied" exception. The same piece of code running from Visual Studio works fine. I was also trying impersation (with levels SecurityImperso nation and SecurityDelegat ion) without effect. If someone can help me I would be really greatful.

    Greetings,
    Tomek
Working...