2013-12-19 2 views
0

proxyAddresses 내용을 업데이트/대체해야하는 C# 스크립트가 있습니다. 나는 다음과 같이 값의 범위를 추가하는 방법을 이해 믿습니다proxyAddresses 값 바꾸기

DirectoryEntry entry = new DirectoryEntry(myConnectString); 
DirectorySearcher Dsearch = new DirectorySearcher(entry); 
Dsearch.Filter = "(sAMAccountName=" + theUser + ")"; 
SearchResult result = Dsearch.FindOne(); 
if (result != null) 
{ 
if (result.Properties.Contains("proxyAddresses")) 
{ 
    DirectoryEntry Uentry = result.GetDirectoryEntry(); 
    Uentry.Properties[proxyAddresses].AddRange(new object[] {"[email protected]", "[email protected]"}); 
    Uentry.CommitChanges(); 
} 
} 

However- 위의 코드에서 오류를 수정 주시기 바랍니다. 이 모양이 올바른지 - 내 이해 AddRange 현재 값을 바꾸기보다는 내 새 값을 추가합니다. 누군가가 내가 어떻게이 새로운 값으로 proxyAddresses의 기존 내용을 제거하거나 바꿀 수 있는지 설명해 주실 수 있습니까? 미리 감사드립니다.

답변

1

이것은 proxyAddresses 속성

Uentry.Properties["proxyAddresses"] = new object[] {"[email protected]", "[email protected]"}; 

있습니다를 대체 할 더 examples about how to work with proxyAddresses here

+0

이이 proxyAddresses의 기존 내용을 교체하거나 단지에 추가 할 것인가? – dev

+0

@dev 대체 할 것입니다 * –

+1

코드가 잘못되어 누군가 내 편집을 거부했습니다. 속성 이름 주변에는 따옴표가 필요합니다. – Mike