Changing credentials for a managed domain
The following code sample changes the credentials used by Adaxes to perfrom operations within a managed domain.
- PowerShell
-
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") $domainName = "example.com" $username = "administrator@example.com" $password = "secret" # Connect to the Adaxes service $admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace" $admService = $admNS.GetServiceDirectly("localhost") # Build ADS path to the managed domain $managedDomainsPath = $admService.Backend.GetConfigurationContainerPath("ManagedDomains") $managedDomainsPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" $managedDomainsPath $managedDomainPath = $managedDomainsPathObj.CreateChildPath("DC=$domainName") # Bind to the domain $managedDomain = $admService.OpenObject($managedDomainPath, $NULL, $NULL, 0) # Provide logon information $managedDomain.Register($username, $password)
- 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"; const String username = "administrator@example.com"; const String passowrd = "secret"; // Connect to the Adaxes service AdmNamespace adsNS = new AdmNamespace(); IAdmService admService = adsNS.GetServiceDirectly("localhost"); // Build ADS path to the managed domain string managedDomainsPath = admService.Backend.GetConfigurationContainerPath( "ManagedDomains"); AdsPath managedDomainsPathObj = new AdsPath(managedDomainsPath); AdsPath managedDomainPath = managedDomainsPathObj.CreateChildPath("DC=" + domainName); // Bind to the domain IAdmManagedDomain managedDomain = (IAdmManagedDomain)admService.OpenObject( managedDomainPath.ToString(), null, null, 0); // Provide logon information managedDomain.Register(username, passowrd); } }
See also
- Writing ADSI scripts
- Server-side scripting
- IAdmTop
- IAdmManagedDomain
- IAdmManagedDomainInfo
- Online script repository