-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.go
435 lines (407 loc) · 14.9 KB
/
server.go
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
package nspi
import (
"context"
"fmt"
"strings"
"unicode/utf16"
dcerpc "github.com/oiweiwei/go-msrpc/dcerpc"
errors "github.com/oiweiwei/go-msrpc/dcerpc/errors"
uuid "github.com/oiweiwei/go-msrpc/midl/uuid"
ndr "github.com/oiweiwei/go-msrpc/ndr"
)
var (
_ = context.Background
_ = fmt.Errorf
_ = utf16.Encode
_ = strings.TrimPrefix
_ = ndr.ZeroString
_ = (*uuid.UUID)(nil)
_ = (*dcerpc.SyntaxID)(nil)
_ = (*errors.Error)(nil)
)
// nspi server interface.
type NspiServer interface {
// The NspiBind method initiates a session between a client and the NSPI server.
//
// Return Values: The server returns a long value specifying the return status of the
// method.
//
// # Exceptions Thrown
//
// No exceptions are thrown beyond those thrown by the underlying RPC protocol, as specified
// in [MS-RPCE].
Bind(context.Context, *BindRequest) (*BindResponse, error)
// The NspiUnbind method destroys the context handle. No other action is taken.
//
// Return Values: The server returns a DWORD value specifying the return status of the
// method.
//
// # Exceptions Thrown
//
// No exceptions are thrown beyond those thrown by the underlying RPC protocol, as specified
// in [MS-RPCE].
Unbind(context.Context, *UnbindRequest) (*UnbindResponse, error)
// The NspiUpdateStat method updates the STAT block representing position in a table
// to reflect positioning changes requested by the client.
//
// Return Values: The server returns a long value specifying the return status of the
// method.
//
// # Exceptions Thrown
//
// No exceptions are thrown beyond those thrown by the underlying RPC protocol, as specified
// in [MS-RPCE].
UpdateStat(context.Context, *UpdateStatRequest) (*UpdateStatResponse, error)
// The NspiQueryRows method returns to the client a number of rows from a specified
// table. The server MUST return no more rows than the number specified in the input
// parameter Count. Although the protocol places no further boundary or requirements
// on the minimum number of rows the server returns, implementations SHOULD return as
// many rows as possible subject to this maximum limit to improve usability of the NSPI
// server for clients.
//
// Return Values: The server returns a long value specifying the return status of
// the method.
//
// # Exceptions Thrown
//
// No exceptions are thrown beyond those thrown by the underlying RPC protocol, as specified
// in [MS-RPCE].
QueryRows(context.Context, *QueryRowsRequest) (*QueryRowsResponse, error)
// The NspiSeekEntries method searches for and sets the logical position in a specific
// table to the first entry greater than or equal to a specified value. Optionally,
// it might also return information about rows in the table.
//
// Return Values: The server returns a long value specifying the return status of the
// method.
//
// # Exceptions Thrown
//
// No exceptions are thrown beyond those thrown by the underlying RPC protocol, as specified
// in [MS-RPCE].
SeekEntries(context.Context, *SeekEntriesRequest) (*SeekEntriesResponse, error)
// The NspiGetMatches method returns an Explicit Table. The rows in the table are chosen
// based on a two possible criteria: a restriction applied to an address book container
// or the values of a property on a single object that hold references to other objects.
//
// Return Values: The server returns a long value specifying the return status of the
// method.
//
// # Exceptions Thrown
//
// No exceptions are thrown beyond those thrown by the underlying RPC protocol, as specified
// in [MS-RPCE].
GetMatches(context.Context, *GetMatchesRequest) (*GetMatchesResponse, error)
// The NspiResortRestriction method applies a sort order to the objects in a restricted
// address book container.
//
// Return Values: The server returns a long value specifying the return status of the
// method.
//
// # Exceptions Thrown
//
// No exceptions are thrown beyond those thrown by the underlying RPC protocol, as specified
// in [MS-RPCE].
ResortRestriction(context.Context, *ResortRestrictionRequest) (*ResortRestrictionResponse, error)
// The NspiDNToMId method maps a set of DN to a set of MId.
//
// Return Values: The server returns a long value specifying the return status of the
// method.
//
// # Exceptions Thrown
//
// No exceptions are thrown beyond those thrown by the underlying RPC protocol, as specified
// in [MS-RPCE].
DNToMID(context.Context, *DNToMIDRequest) (*DNToMIDResponse, error)
// The NspiGetPropList method returns a list of all the properties that have values
// on a specified object.
//
// Return Values: The server returns a long value specifying the return status of the
// method.
//
// # Exceptions Thrown
//
// No exceptions are thrown beyond those thrown by the underlying RPC protocol, as specified
// in [MS-RPCE].
GetPropertyList(context.Context, *GetPropertyListRequest) (*GetPropertyListResponse, error)
// The NspiGetProps method returns an address book row containing a set of the properties
// and values that exist on an object.
//
// Return Values: The server returns a long value specifying the return status of the
// method.
//
// # Exceptions Thrown
//
// No exceptions are thrown beyond those thrown by the underlying RPC protocol, as specified
// in [MS-RPCE].
GetProperties(context.Context, *GetPropertiesRequest) (*GetPropertiesResponse, error)
// The NspiCompareMIds method compares the position in an address book container of
// two objects identified by MId and returns the value of the comparison.
//
// Return Values: The server returns a long value specifying the return status of the
// method.
//
// # Exceptions Thrown
//
// No exceptions are thrown beyond those thrown by the underlying RPC protocol, as specified
// in [MS-RPCE].
CompareMIDs(context.Context, *CompareMIDsRequest) (*CompareMIDsResponse, error)
// The NspiModProps method is used to modify the properties of an object in the address
// book.
//
// Return Values: The server returns a long value specifying the return status of the
// method.
//
// # Exceptions Thrown
//
// No exceptions are thrown beyond those thrown by the underlying RPC protocol, as specified
// in [MS-RPCE].
ModifyProperties(context.Context, *ModifyPropertiesRequest) (*ModifyPropertiesResponse, error)
// The NspiGetSpecialTable method returns the rows of a special table to the client.
// The special table can be an Address Book Hierarchy Table or an Address Creation Table.
//
// Return Values: The server returns a long value specifying the return status of the
// method.
//
// # Exceptions Thrown
//
// No exceptions are thrown beyond those thrown by the underlying RPC protocol, as specified
// in [MS-RPCE].
GetSpecialTable(context.Context, *GetSpecialTableRequest) (*GetSpecialTableResponse, error)
// The NspiGetTemplateInfo method returns information about template objects in the
// address book.
//
// Return Values: The server returns a long value specifying the return status of the
// method.
//
// # Exceptions Thrown
//
// No exceptions are thrown beyond those thrown by the underlying RPC protocol, as specified
// in [MS-RPCE].
GetTemplateInfo(context.Context, *GetTemplateInfoRequest) (*GetTemplateInfoResponse, error)
// The NspiModLinkAtt method modifies the values of a specific property of a specific
// row in the address book.
//
// Return Values: The server returns a long value specifying the return status of the
// method.
//
// # Exceptions Thrown
//
// No exceptions are thrown beyond those thrown by the underlying RPC protocol, as specified
// in [MS-RPCE].
ModifyLinkAttribute(context.Context, *ModifyLinkAttributeRequest) (*ModifyLinkAttributeResponse, error)
// Opnum15NotUsedOnWire operation.
// Opnum15NotUsedOnWire
// The NspiQueryColumns method returns a list of all the properties the NSPI server
// is aware of. It returns this list as an array of proptags.
//
// Return Values: The server returns a long value specifying the return status of the
// method.
//
// # Exceptions Thrown
//
// No exceptions are thrown beyond those thrown by the underlying RPC protocol, as specified
// in [MS-RPCE].
QueryColumns(context.Context, *QueryColumnsRequest) (*QueryColumnsResponse, error)
// The NspiGetNamesFromIDs method returns a list of property names for a set of proptags.
//
// Return Values: The server returns a long value specifying the return status of the
// method.
//
// # Exceptions Thrown
//
// No exceptions are thrown beyond those thrown by the underlying RPC protocol, as specified
// in [MS-RPCE].
GetNamesFromIDs(context.Context, *GetNamesFromIDsRequest) (*GetNamesFromIDsResponse, error)
// The NspiGetIDsFromNames method returns a list of proptags for a set of property names.
//
// Return Values: The server returns a long value specifying the return status of the
// method.
//
// # Exceptions Thrown
//
// No exceptions are thrown beyond those thrown by the underlying RPC protocol, as specified
// in [MS-RPCE].
GetIDsFromNames(context.Context, *GetIDsFromNamesRequest) (*GetIDsFromNamesResponse, error)
// The NspiResolveNames method takes a set of string values in an 8-bit character set
// and performs ANR (as specified in 3.1.1.6) on those strings. The server reports the
// MId that are the result of the ANR process. Certain property values are returned
// for any valid MIds identified by the ANR process.
//
// Return Values: The server returns a long value specifying the return status of the
// method.
//
// # Exceptions Thrown
//
// No exceptions are thrown beyond those thrown by the underlying RPC protocol, as specified
// in [MS-RPCE].
ResolveNames(context.Context, *ResolveNamesRequest) (*ResolveNamesResponse, error)
// The NspiResolveNamesW method takes a set of string values in the Unicode character
// set and performs ANR (as specified in 3.1.1.6) on those strings. The server reports
// the MId that are the result of the ANR process. Certain property values are returned
// for any valid MIds identified by the ANR process.
//
// Return Values: The server returns a long value specifying the return status of the
// method.
//
// # Exceptions Thrown
//
// No exceptions are thrown beyond those thrown by the underlying RPC protocol, as specified
// in [MS-RPCE].
ResolveNamesW(context.Context, *ResolveNamesWRequest) (*ResolveNamesWResponse, error)
}
func RegisterNspiServer(conn dcerpc.Conn, o NspiServer, opts ...dcerpc.Option) {
conn.RegisterServer(NewNspiServerHandle(o), append(opts, dcerpc.WithAbstractSyntax(NspiSyntaxV56_0))...)
}
func NewNspiServerHandle(o NspiServer) dcerpc.ServerHandle {
return func(ctx context.Context, opNum int, r ndr.Reader) (dcerpc.Operation, error) {
return NspiServerHandle(ctx, o, opNum, r)
}
}
func NspiServerHandle(ctx context.Context, o NspiServer, opNum int, r ndr.Reader) (dcerpc.Operation, error) {
switch opNum {
case 0: // NspiBind
in := &BindRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.Bind(ctx, in)
return resp.xxx_ToOp(ctx), err
case 1: // NspiUnbind
in := &UnbindRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.Unbind(ctx, in)
return resp.xxx_ToOp(ctx), err
case 2: // NspiUpdateStat
in := &UpdateStatRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.UpdateStat(ctx, in)
return resp.xxx_ToOp(ctx), err
case 3: // NspiQueryRows
in := &QueryRowsRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.QueryRows(ctx, in)
return resp.xxx_ToOp(ctx), err
case 4: // NspiSeekEntries
in := &SeekEntriesRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.SeekEntries(ctx, in)
return resp.xxx_ToOp(ctx), err
case 5: // NspiGetMatches
in := &GetMatchesRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.GetMatches(ctx, in)
return resp.xxx_ToOp(ctx), err
case 6: // NspiResortRestriction
in := &ResortRestrictionRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.ResortRestriction(ctx, in)
return resp.xxx_ToOp(ctx), err
case 7: // NspiDNToMId
in := &DNToMIDRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.DNToMID(ctx, in)
return resp.xxx_ToOp(ctx), err
case 8: // NspiGetPropList
in := &GetPropertyListRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.GetPropertyList(ctx, in)
return resp.xxx_ToOp(ctx), err
case 9: // NspiGetProps
in := &GetPropertiesRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.GetProperties(ctx, in)
return resp.xxx_ToOp(ctx), err
case 10: // NspiCompareMIds
in := &CompareMIDsRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.CompareMIDs(ctx, in)
return resp.xxx_ToOp(ctx), err
case 11: // NspiModProps
in := &ModifyPropertiesRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.ModifyProperties(ctx, in)
return resp.xxx_ToOp(ctx), err
case 12: // NspiGetSpecialTable
in := &GetSpecialTableRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.GetSpecialTable(ctx, in)
return resp.xxx_ToOp(ctx), err
case 13: // NspiGetTemplateInfo
in := &GetTemplateInfoRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.GetTemplateInfo(ctx, in)
return resp.xxx_ToOp(ctx), err
case 14: // NspiModLinkAtt
in := &ModifyLinkAttributeRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.ModifyLinkAttribute(ctx, in)
return resp.xxx_ToOp(ctx), err
case 15: // Opnum15NotUsedOnWire
// Opnum15NotUsedOnWire
return nil, nil
case 16: // NspiQueryColumns
in := &QueryColumnsRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.QueryColumns(ctx, in)
return resp.xxx_ToOp(ctx), err
case 17: // NspiGetNamesFromIDs
in := &GetNamesFromIDsRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.GetNamesFromIDs(ctx, in)
return resp.xxx_ToOp(ctx), err
case 18: // NspiGetIDsFromNames
in := &GetIDsFromNamesRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.GetIDsFromNames(ctx, in)
return resp.xxx_ToOp(ctx), err
case 19: // NspiResolveNames
in := &ResolveNamesRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.ResolveNames(ctx, in)
return resp.xxx_ToOp(ctx), err
case 20: // NspiResolveNamesW
in := &ResolveNamesWRequest{}
if err := in.UnmarshalNDR(ctx, r); err != nil {
return nil, err
}
resp, err := o.ResolveNamesW(ctx, in)
return resp.xxx_ToOp(ctx), err
}
return nil, nil
}