简体   繁体   English

从 C# 应用程序打开 Active Directory 用户和计算机属性表

[英]Open Active Directory Users and Computers Property Sheet from a C# Application

I would like to open the property sheets for users, groups etc of the 'Active Directory Users and Computers' console from a C# application.我想从 C# 应用程序打开“Active Directory 用户和计算机”控制台的用户、组等的属性表。

Has anyone an idea how to do it?有没有人知道怎么做?

I've found an example in the Windows Server 2003 Platform SDK.我在 Windows Server 2003 Platform SDK 中找到了一个示例。 Unfortunately it's in C++, very long, very complex and doesn't work with 64bit operating systems.不幸的是,它是用 C++ 编写的,很长,很复杂,并且不适用于 64 位操作系统。

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.但我认为一个解决方案可能是一个 C++ 中的小库,它只打开属性表并充当 C# 应用程序的包装器。

Kind regards from Hamburg, Marc来自汉堡的亲切问候,马克

This Microsoft sample from GitHub works with 64bit systems.这个来自 GitHub 的Microsoft 示例适用于 64 位系统。 You pass an ADS path as parameter and it calls the property window.您将 ADS 路径作为参数传递并调用属性窗口。

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

It is important that it is case sensitive, so "ldap://.." doesn't work.区分大小写很重要,因此“ldap://..”不起作用。 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:该代码绝对不是为了在终止之前多次调用而设计的,因此它可能是使用 exe 而不进行类似更改的最佳方式:

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 (eq adding a missing class unregister).对于从 C# 直接调用,需要进行一些更改(例如添加缺少的类注销)。 This works for me: How to open the "Active Directory Users and Computers" object properties dialog from c#?这对我有用: How to open the "Active Directory Users and Computers" object properties dialog from c#?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM