[Questions] Lỗi khi gọi phuơng thức INVOKE("ChangePassword",new Object[]{"pass1@","pass2@"});

#1
This is my code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.DirectoryServices;


namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{
// su dung tai khoan user hoac admin de thay thoi mat khau
//tai khoan phai ton tai trong danh sach user account
//kiem tra xem mat khau cu nhap vao co trung voi mat khau login
// thuc hien task doi mat khau va luu lai mat khau moi
string adminAccountName = "administrator";
string adminPassword = "abc@123";
string OldPassword = "123456a@";
string NewPassword = "123456789a@";
DirectoryEntry entry = new DirectoryEntry(
"LDAP://192.168.0.112/CN=Users,DC=dthink,DC=com",
@"dthink.com\"+adminAccountName+"", adminPassword,
AuthenticationTypes.Secure |
AuthenticationTypes.Sealing |
AuthenticationTypes.ServerBind);
DirectorySearcher ds = new DirectorySearcher(entry);
ds.Sort.PropertyName = "CN";
ds.Filter = "(SAMAccountName=ducnv)";
SearchResult result = ds.FindOne();
DirectoryEntry user = result.GetDirectoryEntry();
try
{
Object ret = user.Invoke("SetPassword", new object[] {OldPassword});
user.CommitChanges();
Console.WriteLine("Change pass thanh cong");
}
catch (StackOverflowException ex)
{
Console.WriteLine(ex.Message);
}
}
catch (DirectoryServicesCOMException exception)
{
Console.WriteLine(exception.Message);
}
Console.ReadLine();
}


}
}
 

Similar threads

Khuyến mãi vps
Top