internal static void PerformSetPassword(string partitionDN, ADObject directoryObj, SecureString newPassword) { ADSessionInfo sessionInfo = directoryObj.SessionInfo; using (ADAccountManagement aDAccountManagement = new ADAccountManagement(sessionInfo)) { IntPtr bSTR = Marshal.SecureStringToBSTR(newPassword); string stringUni = Marshal.PtrToStringUni(bSTR); aDAccountManagement.SetPassword(partitionDN, directoryObj.DistinguishedName, stringUni); } }
public static string ConvertPath(ADSessionInfo sessionInfo, string path, ADPathFormat fromFormat, ADPathFormat toFormat) { string str; if (fromFormat != toFormat) { if (fromFormat == ADPathFormat.Canonical && !string.IsNullOrEmpty(path) && CanonicalPath.IndexOfFirstDelimiter(path) == -1) { path = string.Concat(path, "/"); } using (ADAccountManagement aDAccountManagement = new ADAccountManagement(sessionInfo)) { str = aDAccountManagement.TranslateName(path, fromFormat, toFormat); } return str; } else { return path; } }