ActiveDirectory 사용자 개체 터미널 서비스 속성을 읽고 쓸 필요가 있습니다. 나는이 시도 :msTSProfilePath, msTSHomeDirectory 등을 사용하여 C# DirectoryServices UserContext를 확장하는 방법
PrincipalContext context = new PrincipalContext(ContextType.Domain, "CA");
using (context)
{
UserPrincipal user = UserPrincipal.FindByIdentity(context, IdentityType.SamAccountName, "CA\\vlekovic");
if (user != null)
{
DirectoryEntry entry = (DirectoryEntry)user.GetUnderlyingObject();
entry.Properties["msTSProfilePath"].Value = "";
entry.Properties["msTSHomeDirectory"].Value = "";
entry.Properties["msTSHomeDrive"].Value = "";
entry.CommitChanges();
}
}
을 그리고 나는이 시도 :
PrincipalContext context = new PrincipalContext(ContextType.Domain, "CA");
using (context)
{
UserPrincipal user = UserPrincipal.FindByIdentity(context, IdentityType.SamAccountName, "CA\\vlekovic");
if (user != null)
{
DirectoryEntry entry = (DirectoryEntry)user.GetUnderlyingObject();
entry.InvokeSet("msTSProfilePath", "");
entry.InvokeSet("msTSHomeDirectory", "");
entry.InvokeSet("msTSHomeDrive", "");
entry.CommitChanges();
}
}
을하지만 아무것도 작동하지 않습니다.
나는 속성 이름을 다음과 같이 또한 시도 :
- TerminalServicesProfilePath
- TerminalServicesHomeDirectory
- TerminalServicesHomeDrive
그러나 행운. 어떤 도움을 주시면 감사하겠습니다!
감사합니다, 보진
이
당신은 위의 코드는하지 않았다 말할 때 일하는거야, 너는 정교 할 수 있니? 예를 들어 예외가 발생 했습니까? – Nate
예, 다음 오류가 발생합니다. DirectoryServiceCOMExtension이 처리되지 않았습니다. 디렉터리 서비스에 지정된 특성 구문이 유효하지 않습니다. – Vojin