0

I am using ResourceManager in Sytem.Resources class of C#.ResourceManager has a protected constructor, so we cant create the instance directly. I want to use the GetObject function to get the object of WinNT.

I want to do the following :

 IADsOpenDSObject user= (IADsOpenDSObject)Utils.GetObject("WinNT:");

Details about IADsOpenDSObject is available in the following link.

I tried doing the following :

    class ResourceManagerSub : ResourceManager
        {

            public ResourceManagerSub()
            {

            }
        }
    public class Program
    {
       static void Main(string[] args)
            {
                ResourceManagerSub Utils = new ResourceManagerSub();
                IADsOpenDSObject user = (IADsOpenDSObject)Utils.GetObject("WinNT:");
                user.OpenDSObject("WinNT://machinename", Username, Password, (int)ADS_AUTHENTICATION_ENUM.ADS_SECURE_AUTHENTICATION);


             }
      }

But I am getting exception : Object reference not set to an instance of an object.

So how is it possible to instantiate ResourceManager?

cmm user
  • 2,426
  • 7
  • 34
  • 48
  • The ResourceManager class is a million miles removed from COM and Active Directory Services. The WinNT ADSI provider does not have any options to read managed resources from a program on another machine. Putting them together makes no sense at all. – Hans Passant Jun 13 '14 at 10:56
  • The following link gives the Visual Basic implementation to get the object and then use OpenDSObject to bind to the machine -[Link](http://support.microsoft.com/kb/218497/en-us) . How to get the object of WinNT? – cmm user Jun 13 '14 at 11:02
  • Hard to see what that has to do with the code in the question. I can only guess that you fell off this cliff by the usage of the word "Object" in ADS speak. Does not have to anything at all with a .NET object or ResourceManager.GetObject(). The .NET Framework already has direct support for ADS, use the System.DirectoryServices namespace. – Hans Passant Jun 13 '14 at 11:12
  • The following link provides VB implementation of the OpenDSObject method for LDAP provider.[Link](http://msdn.microsoft.com/en-us/library/aa772136(v=vs.85).aspx). I wanted to do the similar thing in C# with WinNT provider. – cmm user Jun 16 '14 at 11:15

0 Answers0