I have a local user who is a member of the local Administrators group.
When I run this code:
using System;
using System.DirectoryServices;
namespace nanttest
{
class Program
{
public static void Main(string[] args)
{
using(DirectoryEntry entry = new DirectoryEntry("IIS://localhost/W3SVC"))
{
object absobject = entry.NativeObject;
Console.WriteLine("Name: {0}", entry.Name);
}
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}
I get:
Unhandled exception: System.Runtime.InteropServices.COMException (0x80070005): access denied.
in System.DirectoryServices.DirectoryEntry.Bind (Boolean throwIfFail) in System.DirectoryServices.DirectoryEntry.Bind () in System.DirectoryServices.DirectoryEntry.get_NativeObject () with nanttest.Program.Main (String [] args) in C: \ Work \ nanttest \ nanttest \ Program.cs: line 20
If I run this code during login as an administrator, it works fine.
, , DomainAdmin. MYDOMAIN\DomainAdmins MYDOMAIN\mydomainuser .
, .