/
ReplicationOperation.cs
82 lines (62 loc) · 2.47 KB
/
ReplicationOperation.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.InteropServices;
using System.Collections;
namespace System.DirectoryServices.ActiveDirectory
{
public class ReplicationOperation
{
private readonly string? _dsaDN;
private readonly DirectoryServer _server;
private string? _sourceServer;
private readonly Hashtable _nameTable;
internal ReplicationOperation(IntPtr addr, DirectoryServer server, Hashtable table)
{
DS_REPL_OP operation = new DS_REPL_OP();
Marshal.PtrToStructure(addr, operation);
// get the enqueued time
TimeEnqueued = DateTime.FromFileTime(operation.ftimeEnqueued);
// get the operation identifier
OperationNumber = operation.ulSerialNumber;
// get the priority
Priority = operation.ulPriority;
// get the operation type
OperationType = operation.OpType;
// get the partition name
PartitionName = Marshal.PtrToStringUni(operation.pszNamingContext);
// get the dsaDN
_dsaDN = Marshal.PtrToStringUni(operation.pszDsaDN);
// get the dsaobject guid
SourceServerGuid = operation.uuidDsaObjGuid;
_server = server;
_nameTable = table;
}
public DateTime TimeEnqueued { get; }
public int OperationNumber { get; }
public int Priority { get; }
public ReplicationOperationType OperationType { get; }
public string? PartitionName { get; }
public string? SourceServer
{
get
{
if (_sourceServer == null)
{
// check whether we have got it before
if (_nameTable.Contains(SourceServerGuid))
{
_sourceServer = (string)_nameTable[SourceServerGuid]!;
}
else if (_dsaDN != null)
{
_sourceServer = Utils.GetServerNameFromInvocationID(_dsaDN, SourceServerGuid, _server)!;
// add it to the hashtable
_nameTable.Add(SourceServerGuid, _sourceServer);
}
}
return _sourceServer;
}
}
private Guid SourceServerGuid { get; }
}
}