Search code examples
c#active-directorydirectoryservices

Domain and Forest objects in .NET


I'd like to be able to use the functionality provided by these framework classes but I also need to ensure that the authentication flag "ReadOnlyServer" gets set since my application will be in a Read Only Domain Controller environment.

These framework objects internally create their own DirectoryEntry objects but don't specify the correct flag. Does anyone know how to force .NET to use different authentication flags?

At the moment any call to Domain.GetCurrentDomain(), or Forest.GetCurrentForest() will either hang or crash my application in a RODC environment.


Solution

  • I'm not aware of any way to alter the built-in behavior. My guess is this decision was made based on the classes supporting modifications and not wanting to change them to be able to chase referrals or something like that. I'd have a quick look on support.microsoft.com and see if there's been a hotfix that would alter this behavior, though.

    You may need to wrap the Win32 APIs instead e.g. DsGetDcName and use that output to build a context to pass to Domain.GetDomain().