/
DsGetDC.java
225 lines (200 loc) · 7.7 KB
/
DsGetDC.java
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package com.sun.jna.platform.win32;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.Guid.GUID;
import com.sun.jna.platform.win32.WinNT.PSID;
import com.sun.jna.win32.StdCallLibrary;
/**
* Ported from DsGetDC.h.
* Windows SDK 6.0a
* @author dblock[at]dblock.org
*/
public interface DsGetDC extends StdCallLibrary {
/**
* The DOMAIN_CONTROLLER_INFO structure is used with the DsGetDcName
* function to receive data about a domain controller.
*/
public static class DOMAIN_CONTROLLER_INFO extends Structure {
public static class ByReference extends DOMAIN_CONTROLLER_INFO implements Structure.ByReference {
}
public DOMAIN_CONTROLLER_INFO() {
}
public DOMAIN_CONTROLLER_INFO(Pointer memory) {
useMemory(memory);
read();
}
/**
* Pointer to a null-terminated WString that specifies the computer name
* of the discovered domain controller. The returned computer name is
* prefixed with "\\". The DNS-style name, for example, "\\phoenix.fabrikam.com",
* is returned, if available. If the DNS-style name is not available, the
* flat-style name (for example, "\\phoenix") is returned. This example would apply
* if the domain is a Windows NT 4.0 domain or if the domain does not support the
* IP family of protocols.
*/
public WString DomainControllerName;
/**
* Pointer to a null-terminated WString that specifies the address of the discovered
* domain controller. The address is prefixed with "\\". This WString is one of the
* types defined by the DomainControllerAddressType member.
*/
public WString DomainControllerAddress;
/**
* Indicates the type of WString that is contained in the DomainControllerAddress member.
*/
public int DomainControllerAddressType;
/**
* The GUID of the domain. This member is zero if the domain controller does not have
* a Domain GUID; for example, the domain controller is not a Windows 2000 domain
* controller.
*/
public GUID DomainGuid;
/**
* Pointer to a null-terminated WString that specifies the name of the domain. The
* DNS-style name, for example, "fabrikam.com", is returned if available. Otherwise,
* the flat-style name, for example, "fabrikam", is returned. This name may be different
* than the requested domain name if the domain has been renamed.
*/
public WString DomainName;
/**
* Pointer to a null-terminated WString that specifies the name of the domain at the root
* of the DS tree. The DNS-style name, for example, "fabrikam.com", is returned if
* available. Otherwise, the flat-style name, for example, "fabrikam" is returned.
*/
public WString DnsForestName;
/**
* Contains a set of flags that describe the domain controller.
*/
public int Flags;
/**
* Pointer to a null-terminated WString that specifies the name of the site where the
* domain controller is located. This member may be NULL if the domain controller is
* not in a site; for example, the domain controller is a Windows NT 4.0 domain
* controller.
*/
public WString DcSiteName;
/**
* Pointer to a null-terminated WString that specifies the name of the site that the
* computer belongs to. The computer is specified in the ComputerName parameter passed
* to DsGetDcName. This member may be NULL if the site that contains the computer
* cannot be found; for example, if the DS administrator has not associated the
* subnet that the computer is in with a valid site.
*/
public WString ClientSiteName;
}
/**
* Pointer to DOMAIN_CONTROLLER_INFO.
*/
public static class PDOMAIN_CONTROLLER_INFO extends Structure {
public static class ByReference extends PDOMAIN_CONTROLLER_INFO implements Structure.ByReference {
}
public DOMAIN_CONTROLLER_INFO.ByReference dci;
}
/**
* Domain is a member of the forest.
*/
public static final int DS_DOMAIN_IN_FOREST = 0x0001;
/**
* Domain is directly trusted.
*/
public static final int DS_DOMAIN_DIRECT_OUTBOUND = 0x0002;
/**
* Domain is root of a tree in the forest.
*/
public static final int DS_DOMAIN_TREE_ROOT = 0x0004;
/**
* Domain is the primary domain of queried server.
*/
public static final int DS_DOMAIN_PRIMARY = 0x0008;
/**
* Primary domain is running in native mode.
*/
public static final int DS_DOMAIN_NATIVE_MODE = 0x0010;
/**
* Domain is directly trusting.
*/
public static final int DS_DOMAIN_DIRECT_INBOUND = 0x0020;
/**
* Valid domain flags.
*/
public static final int DS_DOMAIN_VALID_FLAGS =
DS_DOMAIN_IN_FOREST |
DS_DOMAIN_DIRECT_OUTBOUND |
DS_DOMAIN_TREE_ROOT |
DS_DOMAIN_PRIMARY |
DS_DOMAIN_NATIVE_MODE |
DS_DOMAIN_DIRECT_INBOUND;
/**
* The DS_DOMAIN_TRUSTS structure is used with the DsEnumerateDomainTrusts function to
* contain trust data for a domain.
*/
public static class DS_DOMAIN_TRUSTS extends Structure {
public static class ByReference extends DS_DOMAIN_TRUSTS implements Structure.ByReference {
}
/**
* Pointer to a null-terminated string that contains the NetBIOS name of the domain.
*/
public WString NetbiosDomainName;
/**
* Pointer to a null-terminated string that contains the DNS name of the domain. This member may be NULL.
*/
public WString DnsDomainName;
/**
* Contains a set of flags that specify more data about the domain trust.
*/
public NativeLong Flags;
/**
* Contains the index in the Domains array returned by the DsEnumerateDomainTrusts function that
* corresponds to the parent domain of the domain represented by this structure.
*/
public NativeLong ParentIndex;
/**
* Contains a value that indicates the type of trust represented by this structure.
*/
public NativeLong TrustType;
/**
* Contains a value that indicates the attributes of the trust represented by this structure.
*/
public NativeLong TrustAttributes;
/**
* Contains the security identifier of the domain represented by this structure.
*/
public PSID.ByReference DomainSid;
/**
* Contains the GUID of the domain represented by this structure.
*/
public GUID DomainGuid;
};
/**
* A pointer to an array of DS_DOMAIN_TRUSTS.
*/
public static class PDS_DOMAIN_TRUSTS extends Structure {
public static class ByReference extends PDS_DOMAIN_TRUSTS implements Structure.ByReference {
}
public DS_DOMAIN_TRUSTS.ByReference t;
/**
* Returns domain trusts.
* @param count
* Number of domain trusts.
* @return
* An array of domain trusts.
*/
public DS_DOMAIN_TRUSTS[] getTrusts(int count) {
return (DS_DOMAIN_TRUSTS[]) t.toArray(count);
}
}
}