DirectoryEntry.NativeObject denies access to a user in the Administrators group in Windows 2008

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 .

, .

+2
1

, :

UAC Windows 2008. "", ( , , ).

, 1 - , " " , .

2: UAC . # 3 ( ). .

+6

All Articles