高低を検索してきましたが、ADLDS で変更された属性の古い値を取得する方法の例が見つかりません。変更通知を使用して変更を監視する Web サービスを作成しましたが、正常に動作します。追加、変更、および削除を取得できます。ただし、変更のために古い属性値と新しい属性値を指定できるようにする必要があります。変更された属性のみを返すため、DirSync を使用する必要があると考えています。しかし、それは私に新しい価値を与えるだけのようです。古い属性値が何であったかを返す方法はありますか? これが役立つ場合に備えて、現在使用している DirSync コードを次に示します。
BinaryFormatter bFormat = new BinaryFormatter();
byte[] cookie = null;
string strFileName = "cookie.bin";
if (File.Exists(strFileName))
{
using (FileStream fsStream = new FileStream(strFileName, FileMode.OpenOrCreate))
{
cookie = (byte[])bFormat.Deserialize(fsStream);
}
}
string str_dcName = "xx.x.xx.xx:5000";
LdapConnection connection = new LdapConnection(str_dcName);
connection.SessionOptions.ProtocolVersion = 3;
connection.Credential = new System.Net.NetworkCredential("CN=administrator,ou=blah,dc=blahblah", "password");
connection.AuthType = AuthType.Basic;
connection.Bind();
string[] attribs = new string[4];
attribs[0] = "sn";
attribs[1] = "isDeleted";
attribs[2] = "displayname";
SearchRequest request = new SearchRequest("OU=blah,DC=blahblah", "(|(objectClass=*)(isDeleted=TRUE))", SearchScope.Subtree, attribs);
DirSyncRequestControl dirSyncRC = new DirSyncRequestControl(cookie, DirectorySynchronizationOptions.IncrementalValues, Int32.MaxValue);
request.Controls.Add(dirSyncRC);
bool bMoreData = true;
SearchResponse searchResponse = (SearchResponse)connection.SendRequest(request);
while (bMoreData) //Initial Search handler - since we're unable to combine with paged search
{
foreach (SearchResultEntry entry in searchResponse.Entries)
{
System.Collections.IDictionaryEnumerator attribEnum = entry.Attributes.GetEnumerator();
while (attribEnum.MoveNext())//Iterate through the result attributes
{
//Attributes have one or more values so we iterate through all the values
//for each attribute
DirectoryAttribute subAttrib = (DirectoryAttribute)attribEnum.Value;
for (int ic = 0; ic < subAttrib.Count; ic++)
{
//Attribute Name below
Console.WriteLine(attribEnum.Key.ToString());
//Attribute Sub Value below
Console.WriteLine(subAttrib[ic].ToString());
}
}
}
//Get the cookie from the response to use it in next searches
foreach (DirectoryControl control in searchResponse.Controls)
{
if (control is DirSyncResponseControl)
{
DirSyncResponseControl dsrc = control as DirSyncResponseControl;
cookie = dsrc.Cookie;
bMoreData = dsrc.MoreData;
break;
}
}
dirSyncRC.Cookie = cookie;
searchResponse = (SearchResponse)connection.SendRequest(request);
}
//Serialize the cookie into a file to use in next searches
using (FileStream fsStream = new FileStream(strFileName, FileMode.Create))
{
//Serialize the data to the steam. To get the data for
//the cookie, call the GetDirectorySynchronizationCookie method.
bFormat.Serialize(fsStream, cookie);
}
Console.WriteLine("Finished search...");
Console.ReadKey();
助けてくれてありがとう!!
デイブ