/
TrustRelationshipInformation.cs
62 lines (53 loc) · 1.92 KB
/
TrustRelationshipInformation.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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.DirectoryServices.ActiveDirectory
{
public enum TrustType
{
TreeRoot = 0,
ParentChild = 1,
CrossLink = 2,
External = 3,
Forest = 4,
Kerberos = 5,
Unknown = 6
}
public enum TrustDirection
{
Inbound = 1,
Outbound = 2,
Bidirectional = Outbound | Inbound
}
public class TrustRelationshipInformation
{
internal string? source;
internal string? target;
internal TrustType type;
internal TrustDirection direction;
internal DirectoryContext context = null!;
internal TrustRelationshipInformation() { }
internal TrustRelationshipInformation(DirectoryContext context, string? source, TrustObject obj)
{
// security context
this.context = context;
// source
this.source = source;
// target
this.target = obj.DnsDomainName ?? obj.NetbiosDomainName;
// direction
if ((obj.Flags & (int)DS_DOMAINTRUST_FLAG.DS_DOMAIN_DIRECT_OUTBOUND) != 0 &&
(obj.Flags & (int)DS_DOMAINTRUST_FLAG.DS_DOMAIN_DIRECT_INBOUND) != 0)
direction = TrustDirection.Bidirectional;
else if ((obj.Flags & (int)DS_DOMAINTRUST_FLAG.DS_DOMAIN_DIRECT_OUTBOUND) != 0)
direction = TrustDirection.Outbound;
else if ((obj.Flags & (int)DS_DOMAINTRUST_FLAG.DS_DOMAIN_DIRECT_INBOUND) != 0)
direction = TrustDirection.Inbound;
// type
this.type = obj.TrustType;
}
public string? SourceName => source;
public string? TargetName => target;
public TrustType TrustType => type;
public TrustDirection TrustDirection => direction;
}
}