How to list available ADSI (Active Directory Service Interfaces) service providers?
-
26-09-2019 - |
Question
How can I list available ADSI (Active Directory Service Interfaces) service providers in C#?
Solution
I have found that:
foreach (object obj in (IEnumerable)Marshal.BindToMoniker("ADs:"))
{
obj.GetType().InvokeMember("Name", BindingFlags.DeclaredOnly |
BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Instance |
BindingFlags.GetProperty, null, obj, null).Dump();
}
OTHER TIPS
Microsoft has an KB-233023 on this topic: How To Find All ADSI Providers on a System
another variant:
public static IEnumerable<string> GetAdsiProviders()
{
var providers = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\ADs\Providers");
if (null == providers) yield break;
foreach (var name in providers.GetSubKeyNames())
{
yield return name + ":";
}
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow