2

I would like to open the property sheets for users, groups etc of the 'Active Directory Users and Computers' console from a C# application.

Has anyone an idea how to do it?

I've found an example in the Windows Server 2003 Platform SDK. Unfortunately it's in C++, very long, very complex and doesn't work with 64bit operating systems.

But I think a solution could be a small library in C++ that only opens the property sheet and act as a wrapper for the C# application.

Kind regards from Hamburg, Marc

MarcHH
  • 21
  • 1
  • Regarding the example you found, would you be referring to the 'PropSheetHost' sample console project in C++ in the 'Microsoft Platform SDK for Windows Server 2003 R2'? – T-Heron Dec 30 '16 at 14:58
  • Did you ever figure this out? I'd love to be able to do this too. – Gabriel Luci Nov 27 '18 at 16:37
  • Yes, it's the 'PropSheetHost' Project. And unfortunately no solution until now. – MarcHH Nov 28 '18 at 19:02

1 Answers1

0

This Microsoft sample from GitHub works with 64bit systems. You pass an ADS path as parameter and it calls the property window.

PropSheetHost.exe "LDAP://CN=user,DC=MyDomain,DC=MyTldDomain"

It is important that it is case sensitive, so "ldap://.." doesn't work. The code is definitely not designed to get called multiple times before terminating, so it is probably the best way to use the exe without changes like that:

ProcessStartInfo startInfo = new ProcessStartInfo();        
startInfo.FileName = @"PropSheetHost.exe";
startInfo.Arguments = @"LDAP://CN=user,DC=MyDomain,DC=MyTldDomain";
Process.Start(startInfo);

For a direct call from C# some changes needs to be done (e.q. adding a missing class unregister). This works for me: How to open the "Active Directory Users and Computers" object properties dialog from c#?

marsh-wiggle
  • 2,508
  • 3
  • 35
  • 52