Unregistering managed domains
The following code sample removes a managed domain from Adaxes.
- PowerShell
-
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") $domainName = "example.com" # Connect to the Adaxes service $ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace" $service = $ns.GetServiceDirectly("localhost") # Build ADS path to the managed domain $managedDomainsPath = $service.Backend.GetConfigurationContainerPath("ManagedDomains") $managedDomainsPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" $managedDomainsPath $managedDomainPath = $managedDomainsPathObj.CreateChildPath("DC=$domainName") # Unregister the domain $managedDomain = $service.OpenObject($managedDomainPath, $null, $null, 0) $managedDomain.Unregister()
- C#
-
using System; using Softerra.Adaxes.Adsi; using Softerra.Adaxes.Interop.Adsi.PersistentObjects; class Program { static void Main(string[] args) { const string domainName = "example.com"; // Connect to the Adaxes service AdmNamespace ns = new AdmNamespace(); IAdmService service = ns.GetServiceDirectly("localhost"); // Build ADS path to the managed domain string managedDomainsPath = service.Backend.GetConfigurationContainerPath( "ManagedDomains"); AdsPath managedDomainsPathObj = new AdsPath(managedDomainsPath); AdsPath managedDomainPath = managedDomainsPathObj.CreateChildPath("DC=" + domainName); // Unregister the domain IAdmManagedDomain managedDomain = (IAdmManagedDomain)service.OpenObject( managedDomainPath.ToString(), null, null, 0); managedDomain.Unregister(); } }
See also
- Writing ADSI scripts
- Server-side scripting
- IAdmTop
- IAdmManagedDomain
- IAdmManagedDomainInfo
- Online script repository