LDAP 계정 관리에 대한 질문을 올렸지 만이를 탐색 한 후에는 내가 무엇을했는지 알지 못합니다. 나는 기계에서 사용자를 생성하는 두 가지 방법을 찾았고 하나는 다른 것보다 훨씬 깔끔하다는 것을 알았지 만 첫 번째 옵션을 두 번째 옵션으로 완전히 변환하는 방법을 모릅니다. ActiveDirectory 로컬 컴퓨터 계정 관리 - C#
이 내 최초의 솔루션이었다 Process MyProc = new Process();
MyProc.StartInfo.WorkingDirectory = System.Environment.SystemDirectory;
MyProc.StartInfo.FileName = "net.exe";
MyProc.StartInfo.UseShellExecute = false;
MyProc.StartInfo.RedirectStandardError = true;
MyProc.StartInfo.RedirectStandardInput = true;
MyProc.StartInfo.RedirectStandardOutput = true;
MyProc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
MyProc.StartInfo.Arguments = string.Format(@" user {0} {1} /ADD /ACTIVE:YES /EXPIRES:NEVER /FULLNAME:{0}"" /PASSWORDCHG:NO /PASSWORDREQ:YES", username, password);
MyProc.Start();
MyProc.WaitForExit();
int exit = MyProc.ExitCode;
MyProc.Close();
return exit == 0;
그리고 이것은 내 두 번째 (preffered) 솔루션이었다
DirectoryEntry root = GetDELocalRoot();
DirectoryEntry user = root.Children.Add(username, "user");
//TODO: Always Active
//TODO: Never Expires
//TODO: No Password Change
//TODO: Password Required
user.Properties["description"].Value = "Account for running the MicaService and handling updates.";
user.Invoke("SetPassword", new object[] { password });
user.CommitChanges();
user.Close();
내 TODO의 모든 설정을지도하고 싶은
: 최초의 솔루션에서을 내 두 번째 솔루션으로
은 나뿐만 아니라 다음 줄을 시도 :
user.Properties["userAccountControl"].Value = ADS_USER_FLAG.ADS_UF_NORMAL_ACCOUNT | ADS_USER_FLAG.ADS_UF_PASSWD_CANT_CHANGE | ADS_USER_FLAG.ADS_UF_DONT_EXPIRE_PASSWD;
그러나 속성이 캐시에 존재하지 않는이 작동하지 않습니다.
참고 : GetDELocalRoot() = 새 DirectoryEntry ("WinNT : //"+ Environment.MachineName)를 반환합니다.
입력 해 주셔서 감사합니다.
감사
트리스