C# Error reading domains in different domain


I have this code that works just fine when logged onto a domain:

DirectoryContext context = new DirectoryContext(DirectoryContextType.DirectoryServer, serverIP, username, password);            

var forest1 = Forest.GetForest(context);

using (var forest = Forest.GetForest(context))
    foreach (Domain domain in forest.Domains)
        DirectoryEntry deDomain = domain.GetDirectoryEntry();
        MessageBox.Show(String.Format("{0} {1} {2}", domain.Name, deDomain.Path, deDomain.Guid));

And it also works fine when accessing a domain that I am not logged onto ie. the connection goes through ok and forest.Domains is populated.

The problem I have is that whenever I try to access any property of the domain object (eg. domain.DomainMode) I get 'Unknown error (0x80005000)' - any ideas?

asked on Stack Overflow Nov 27, 2014 by A_L

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0