C# webservice에서 다양한 AD 속성을 프로그래밍 방식으로 업데이트하려고합니다.Active Directory를 업데이트 할 때 "지정한 디렉터리 서비스 특성 또는 값이 이미 있습니다."오류
I 전화/사무실/제목 등 아무 문제를 업데이트 할 수 있습니다,하지만 난 ThumbnailPhoto를 업데이트하려고 할 때 오류 얻을 : 내가 확장 클래스를 통해 업데이트하고 지정한 디렉터리 서비스 특성 또는 값이 이미
존재를 (나는 AD의 레코드를 업데이트하기 위해 사용하고
코드) Get job title using System.DirectoryServices.AccountManagement 당과 같습니다
public ADRecord UpdateADRecord(string UserName)
{
DeltekRecord dr = GetDeltekRecord(UserName);
UserPrincipalEx upx = GetUser(UserName);
upx.Office = GetFriendlyFieldName(dr.Office);
upx.MobilePhone = dr.MobilePhone;
upx.TelephoneNumber = dr.WorkPhone;
upx.Department = GetFriendlyFieldName(dr.BusinessUnit);
upx.Title = dr.Title;
// Handle Company
string Company = "";
if ((dr.Org ?? "").Contains(":FOO:"))
Company = "Foo";
else
Company = "Bar";
upx.Company = Company;
// Handle Home Phone
string HomeNo = "";
if ((dr.WorkPhone.Length > 0) && (dr.Office.Length > 0))
{
switch (dr.Office.ToLower()) {
case "washington":
HomeNo = "8" + dr.WorkPhone.Substring(dr.WorkPhone.Length - 3, 3);
break;
case "ohio":
HomeNo = "9" + dr.WorkPhone.Substring(dr.WorkPhone.Length - 3, 3);
break;
case "nooyoik":
HomeNo = "2" + dr.WorkPhone.Substring(dr.WorkPhone.Length - 3, 3);
break;
default:
HomeNo = "";
break;
}
}
upx.Thumbnail = null;
upx.Thumbnail = GetThumbnail(dr.Employee);
upx.Save();
ADRecord adr = GetADRecord(UserName);
return adr;
}
일부 인터넷 검색을 내가 미리가 처음 속성을 삭제해야합니다 제안합니다. 위와 같이 null로 설정하려고 시도했지만 기쁨은 없습니다.
편집 : 추가 방법은 내가 UserPrincipalEx에 익숙하지 않은,하지만 난 당신이 썸네일을 설정 한 후 실제로 명확를 null로 저장 함수를 호출해야 같은데요
// Get the relevant details from AD
[WebMethod]
public ADRecord GetADRecord(string userName)
{
ADRecord adr = new ADRecord();
PrincipalContext oPrincipalContext = GetPrincipalContext();
// Search the directory for the new object.
UserPrincipalEx myUser = UserPrincipalEx.FindByIdentity(oPrincipalContext, userName);
if (myUser != null)
{
adr.Company = myUser.Company;
adr.Department = myUser.Department;
adr.HomePhone = myUser.HomePhone;
adr.MobilePhone = myUser.MobilePhone;
adr.Office = myUser.Office;
adr.TelephoneNumber = myUser.TelephoneNumber;
adr.ThumbNail = myUser.Thumbnail;
adr.Title = myUser.Title;
}
return adr;
}
// Get the user's thumbnail
[WebMethod]
public byte[] GetThumbnail(int EmpNo)
{
System.Net.WebClient wclient = new System.Net.WebClient();
wclient.Credentials = new System.Net.NetworkCredential("user","pass", "domain");
string url = "http://myurl.mycompany.com/PeopleEmployeePhoto.ashx?Employee=" + EmpNo;
byte[] imageData;
using (wclient)
{
imageData = wclient.DownloadData(new Uri(url));
}
return imageData;
}
당신은 그 방법이 무엇인지를 보여주지 않는 아래 2 가지 방법을 가지고 있습니다. 하나는 마음 독자가됩니다 ... 이미지가 그들의 가치와 속성을 어떻게 얻고 있는지 보여주세요. 또한 광고의 일부를 감쌀 수 있습니까? 예를 들어 GetUserName의 코드가 트랩되지 않는 오류가 있습니다. – MethodMan