-
Notifications
You must be signed in to change notification settings - Fork 0
/
SUMMARY.API.txt
10163 lines (7592 loc) · 406 KB
/
SUMMARY.API.txt
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
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Lan Manager API Table of Contents
1. Introduction and Overview .... 1
1.1 Architecture of the API
1.2 Using APIs Remotely
1.3 Admin Rights
1.4 API Naming Convention
1.5 API Parameters and Data Structures
1.5.1 ASCIZ Strings
1.5.2 Structure Alignment
1.5.3 Level of Detail
1.5.4 Fixed-Length and Variable-Length Data
1.6 Return Values
1.7 GetInfo Calls
1.8 Enum Calls
1.9 SetInfo Calls
1.10 Time Stamps
1.11 Calling Lan Manager APIs
1.11.1 Calling APIs from Microsoft C
1.11.2 Calling APIs from Assembly Language
1.11.3 Linking to the API Libraries
1.12 Protection Violations and Faults in the DLL
1.13 General Error Codes
2. SHARES .... 13
2.1 NetShareEnum
2.2 NetShareGetInfo
2.3 NetShareSetInfo (Admin only)
2.4 NetShareAdd (Admin only)
2.5 NetShareDel (Admin only)
2.6 NetShareCheck
3. SESSIONS .... 19
3.1 NetSessionEnum (Admin only)
3.2 NetSessionGetInfo (Admin only)
3.3 NetSessionDel (Admin only)
4. CONNECTIONS .... 22
4.1 NetConnectionEnum (Admin only)
5. FILES .... 24
5.1 NetFileEnum (Admin only)
5.2 NetFileGetInfo (Admin only)
5.3 NetFileClose (Admin only)
6. SERVER .... 26
6.1 NetServerEnum
6.2 NetServerGetInfo (Admin only)
6.3 NetServerSetInfo (Admin only)
6.4 NetServerDiskEnum (Admin Only)
6.5 NetServerAdminCommand (Admin only)
7. AUDITING .... 33
7.1 NetAuditOpen (Admin only)
7.2 NetAuditWrite (Admin only) (Local only)
7.3 NetAuditClear (Admin only)
8. ERROR LOGGING .... 42
8.1 NetErrorLogOpen (Admin only)
8.2 NetErrorLogWrite (Admin only) (Local only)
8.3 NetErrorLogClear (Admin only)
9. CHARACTER DEVICES .... 46
9.1 NetCharDevEnum
9.2 NetCharDevGetInfo
9.3 NetCharDevControl (Admin only)
9.4 NetCharDevQEnum
9.5 NetCharDevQGetInfo
9.6 NetCharDevQSetInfo (Admin only)
9.7 NetCharDevQPurge (Admin only)
9.8 NetCharDevQPurgeSelf
10. MESSAGE SERVER .... 52
10.1 NetMessageNameEnum
10.2 NetMessageNameGetInfo
10.3 NetMessageNameAdd
10.4 NetMessageNameDel
10.5 NetMessageNameFwd
10.6 NetMessageNameUnFwd
10.7 NetMessageBufferSend
10.8 NetMessageFileSend
10.9 NetMessageLogFileSet
10.10 NetMessageLogFileGet
11. SERVICE .... 59
11.1 General Information
11.1.1 Data Structures
11.1.2 UIC (Uninstall) Codes
11.1.3 IP (Install Pending) Codes
11.2 NetServiceGetInfo
11.3 NetServiceEnum
11.4 NetServiceInstall
11.5 NetServiceControl
11.6 NetServiceStatus
12. CONFIG .... 69
12.1 NetConfigGet
12.2 NetConfigGetAll
13. ALERT .... 71
13.0.1 Print Alert, Class-specific Information
13.0.2 Message Alert, Class-specific Information
13.0.3 Errlog Alert, Class-specific Information
13.0.4 Admin Alert, Class-specific Information
13.0.5 User Alert, Class-specific Information
13.1 NetAlertStart
13.2 NetAlertStop
13.3 NetAlertRaise
14. ACCESS PERMISSIONS .... 77
14.1 General Information
14.2 NetAccessEnum
14.3 NetAccessGetInfo
14.4 NetAccessSetInfo
14.5 NetAccessAdd (Admin only)
14.6 NetAccessDel (Admin only)
14.7 NetAccessCheck
15. GROUPS .... 83
15.1 NetGroupEnum (Admin only)
15.2 NetGroupAdd (Admin Only)
15.3 NetGroupDel (Admin Only)
15.4 NetGroupAddUser (Admin only)
15.5 NetGroupDelUser (Admin only)
15.6 NetGroupGetUsers (Admin only)
16. USERS .... 87
16.1 NetUserEnum (Admin only)
16.2 NetUserAdd (Admin Only)
16.3 NetUserDel (Admin Only)
16.4 NetUserGetInfo (Admin only)
16.5 NetUserSetInfo (Admin Only)
16.6 NetUserPasswordSet
16.7 NetUserValidate
16.8 NetUserGetGroups (Admin only)
17. WORK STATIONS .... 92
17.1 NetWkstaGetInfo
17.2 NetWkstaSetInfo (Admin Only)
17.3 NetWkstaSetUID (Admin Only)
18. REDIRECT / USE .... 98
18.1 NetUseEnum (Admin only)
18.2 NetUseAdd (Admin only)
18.3 NetUseDel (Admin only)
18.4 NetUseGetInfo (Admin only)
19. PRINT QUEUES .... 104
19.1 DosPrintQEnum
19.2 DosPrintQGetInfo
19.3 DosPrintQSetInfo (Admin only)
19.4 DosPrintQAdd (Admin only)
19.5 DosPrintQDel (Admin only)
19.6 DosPrintQPurge (Admin only)
19.7 DosPrintQPause (Admin only)
19.8 DosPrintQContinue
20. PRINT JOBS .... 110
20.1 DosPrintJobEnum
20.2 DosPrintJobGetInfo
20.3 DosPrintJobSetInfo
20.4 DosPrintJobAdd
20.5 DosPrintJobSchedule
20.6 DosPrintJobDel
20.7 DosPrintJobPause
20.8 DosPrintJobContinue
20.9 DosPrintJobGetId
21. PRINT DESTINATIONS .... 116
21.1 DosPrintDestEnum
21.2 DosPrintDestGetInfo
21.3 DosPrintDestControl (Admin only)
21.4 DosPrintDestStatus
21.5 Writing a Print Queue Processor
22. PIPES .... 121
22.1 DosMakeNmPipe
22.2 DosQNmPipeInfo
22.3 DosConnectNmPipe
22.4 DosDisconnectNmPipe
22.5 DosQNmpHandState
22.6 DosSetNmpHandState
22.7 DosPeekNmPipe
22.8 DosTransactNmPipe
22.9 DosCallNmPipe
22.10 DosWaitNmPipe
22.11 DosQNmPipeSemState
22.12 DosSetNmPipeSem
22.13 DosOpen
22.14 DosClose
22.15 DosDupHandle
22.16 DosQHandType
22.17 DosQFHandState
22.18 DosSetFHandState
22.19 DosWrite, DosWriteAsync
22.20 DosRead, DosReadAsync
22.21 DosBufReset
23. MAILSLOTS .... 132
23.1 DosMakeMailslot
23.2 DosDeleteMailslot
23.3 DosMailslotInfo
23.4 DosReadMailslot
23.5 DosPeekMailslot
23.6 DosWriteMailslot
24. PROFILE .... 137
24.1 NetProfileSave (Admin Only)
24.2 NetProfileLoad (Admin Only)
25. STATISTICS .... 141
25.1 NetStatisticsGet (Admin only)
25.2 NetStatisticsClear (Admin only)
26. NETBIOS .... 144
26.1 NetBiosEnum (Admin Only)
26.2 NetBiosGetInfo (Admin Only)
26.3 NetBiosOpen
26.4 NetBiosClose
26.5 NetBiosSubmit
27. REMOTE UTILITIES .... 150
27.1 NetRemoteTOD
27.2 NetRemoteCopy
27.3 NetRemoteMove
27.4 NetRemoteExec
28. Standard Lan Manager Services .... 155
28.1 Workstation Service
28.2 Server Service
28.3 Spooler Service
28.4 Messenger Service
28.5 Alerter Service
28.6 NetPopup Service
28.7 RunServer Service
28.8 NetLogon Service
29. Writing Lan Manager Service Programs .... 159
29.1 Summary of Service Program Requirements
29.2 Services and LANMAN.INI
29.3 A Day in the Life of a Lan Manager Service Program
29.4 Communication Amongst Applications, Lan Manager, and the Service
29.4.1 Services and NetServiceControl
29.4.2 Services and NetServiceStatus
29.4.3 Other NetService APIs.
29.4.4 The Signal Handler
29.5 Service Startup
29.6 Service Operation
29.7 Service Pause and Continue
29.8 Service Shutdown
29.9 Multi-Process Services
30. Alphabetical List of APIs .... 167
31. OS/2 NETBIOS DEVICE DRIVER INTERFACE .... 169
31.1 Introduction
31.2 Netbios Driver Configuration
31.3 Netbios Driver Initialization
31.4 Netbios NCB Handler
31.5 Common problems and hints
Microsoft LAN Manager API
1. Introduction and Overview
This document describes the Applications Programming Interface
(API) for the Microsoft OS/2 LAN Manager. Read it carefully,
ESPECIALLY THIS CHAPTER. This initial chapter provides essential
information on the API system as a whole. The remaining chapters can
be used as a reference for the various API functions, but will make
only brief mention of topics covered in the first chapter.
The Applications Programming Interfaces (API) for the Microsoft LAN
Manager give access to network functions through a well-defined
interface for high level languages. The API provides two categories
of functions:
- applications oriented calls: These calls allow network
aware applications to perform functions such as using or
unusing network resources, interrogating or controlling
remotely spooled printing, sending or receiving network
messages, etc.
- administration oriented calls: These calls allow complete
access to or control over local remote server functions.
Examples start or stop server programs, share or unshare
server resources, interrogate/control server sessions, etc.
You should print out a copy of the file NETCONS.H for reference
when reading this document. NETCONS.H defines many of the sizes
of items in the API data structures. In this document such sizes
are given only symbolically, using the manifests defined in NETCONS.H.
1.1 Architecture of the API
All of the OS/2 Lan Manager APIs are in Dynamic Link Libraries
(DLLs). Applications may access these APIs using the same methods as
they access the OS/2 API DLLs. Standard LIB files have been provided
to simplify the task; applications need only link with the proper
LIB files, and the loader will complete any references to the Lan
Manager APIs at application load time.
1.2 Using APIs Remotely
The API allows remote servers and server resources to be controlled
just like local resources. Most functions have a servername
parameter that indicates the machine which is the target of the
operation, and is of the form "\\SERVERNAME". This parameter is NULL
when the operation is performed locally.
A servername which matches the local machine will cause the
operation to be performed locally, just as if NULL were specified
for that parameter.
To protect remote systems, some APIs require admin privilege on the
part of the caller, or they will be rejected by a remote machine.
Such calls are marked "Admin Only". Such security is not implemented
for local calls, only for remote calls. See the next section for
more information on Admin Rights.
Some APIs require that certain services be running, for example the
DosPrint APIs require the Spooler service. This requirement is only
for LOCAL operation. As long as the Workstation service is running,
any API which can has a remote-servername parameter can be used
remotely, provided the remote server specified accepts the call.
This allows an application to, for example, query the status of
print queues on a server, even though the local spooler is not
running.
In order to use APIs remotely to a server, that server must be sharing
IPC$, the special inter-process communication (IPC) share. You
can do this from the command line (on the server) by typing
"NET SHARE IPC$", or from a program using the NetShareAdd API. If
you attempt to remote an API to a server which is not sharing IPC$,
you will be the error NERR_BadTransactConfig. User-security servers
automatically share IPC$ and ADMIN$ at startup, but share-security
servers do not.
For more infomation about user and share security, see the Microsoft
LAN Manager Administrator's Guide.
1.3 Admin Rights
Some APIs require admin rights when you attempt to execute them
remotely. These APIs are marked "Admin Only" in the reference.
Other APIs will have restricted operation for non-admin users.
Such restrictions are noted in the reference.
An API which fails because of lack of admin privilege for a
remote operation which requires it, will return
ERROR_NETWORK_ACCESS_DENIED.
The determination of admin rights depends on the type of server you
are accessing. On user security servers, a user has ADMIN rights if
the user's privilege level (in the user account definition) is
ADMIN. On share security servers, a user has ADMIN rights if the
user has a connection to the ADMIN$ share; the ADMIN$ share should
have a password to prevent unauthorized users from connecting to it
and thus gaining admin rights.
Note that "Admin" calls can always be executed on the local system.
The restrictions are only on calls made to remote machines.
1.4 API Naming Convention
The Lan Manager API is partitioned into categories according to the
resources that it lets you manipulate, such as network sessions,
shared devices, user and group lists, etc. For example, all APIs
dealing with the workstation are called NetWksta<something>.
Each API also contains a "verb". There are verbs for adding and
deleting resources, enumerating defined resources, getting and
setting resource parameters, and performing control operations on
resources. The common API verbs are as follows:
Add Add the specified resource. The parameters
for the new resource are supplied.
Del Delete the named resource.
GetInfo Return parameters for the named resource. All or
partial parameters can be requested.
SetInfo Change parameters for the named resource. All or
partial parameters can be changed.
Enum Enumerate the names of all defined resources of the
specified type (e.g., all print queue names or print job IDs).
Optionally provide full parameter information for each
one (as in GetInfo).
There are several other miscellaneous verbs that have specific
functions for specific resources (eg, NetServiceControl to
pause/continue network services and NetWkstaSetUID to set the local
username and ID).
The following function categories are defined by the Lan Manager API:
Class Description
----- -----------
WORKSTATION workstation configuration information
USE workstation use of network resources
MESSAGING user to user messaging
ALERT monitor and raise network alerts
PIPES two way interprocess communication
MAILSLOTS one way interprocess communication
NETBIOS direct access to NETBIOS drivers
PROFILE save/restore active uses/shares
CONFIG get entries from the LANMAN.INI file
SERVICE install, control, and query network services
SERVER server configuration and statistics
SHARES server file and device shares
SESSIONS server machine sessions
CONNECTIONS server user connections
FILES server open files
AUDITING audit trail logging
ERROR LOGGING system error logging
CHAR DEVICES remote character device connections
PRINT QUEUES spooler job queues
PRINT JOBS spooler print jobs
PRINT DESTINATIONS virtual devices in the spooler
ACCESS access permissions for files and other resource
GROUP group definition and membership
USER user accounts
STATISTICS workstation and server operating statistics
REMOTE remote execution functions
1.5 API Parameters and Data Structures
The API function parameters are defined in the reference sections
on each API. Note that all pointers are declared "far". Even when
calling the API functions from small-model programs, far pointers
must be provided.
Data structures are defined using C syntax. Where such syntax cannot
describe the structure, approximations are used. For example, a
structure holding an unsigned integer and a signed integer, followed
by two ASCIZ strings, would be defined as follows:
struct x
{
unsigned int x_a;
int x_b;
}
followed by:
x_name1[]; /* ASCIZ */
x_name2[]; /* ASCIZ */
1.5.01 ASCIZ Strings
Fields noted as ASCIZ are nul-terminated ASCII strings, the string
type used by C. This is a sequence of non-zero bytes terminated by a
zero byte.
o Where the field is an array, the whole string fits in the
array given. Such arrays are usually declared with a size
of "X+1", to allow room for the terminating nul byte.
o Where the field is a pointer, it points to an area of memory
whch contains the ASCIZ string. Use of a pointer allows the
size of the string to not be fixed by the structure definition.
o Where the field is an unsized array, designated by the pseudo-C
code "x[]" or "x[..]", the ASCIZ string is defined as beginning
after some other field, or at some offset from the structure.
Such strings may be defined to occur in series, as "x_name1" and
"x_name2" above. The second string begins immediately after
the end (bul byte) of the first string.
1.5.02 Structure Alignment
The Lan Manager data structures are intended to be used with or
without packing (Microsoft C 5.1 option -Zp). Fields called "pad",
such as shi1_pad1 in the structure "share_info_1", are used to pad
the structure and word align the next element. Where a structure
ends with such a pad byte, it exists to force the structure to be an
even number of bytes, so that an array of such structures will be
word-aligned. It is up to the application to insure that the start
of such a structure is on a word boundary.
1.5.03 Level of Detail
Some data structures are provided with various levels of detail.
Each level of information is represented by a C structure. The more
detailed levels usually include all the information in the previous
level. Although this is NOT guaranteed to always be true in the
future, it is true in all current structures.
Where an API accepts or provides more than one level of information,
a parameter is provided to indicate the level of information
desired/provided. Some calls, such as Add, may require a specific
level. If an unacceptable level parameter is passed to an API
function, the function will return ERROR_INVALID_LEVEL.
Not all fields are fully readable and writeable, for example the
password field of a user_info_1 structure will be returned as a null
string always. GetInfo and Enum will return unreadable parameters as
null. Add and SetInfo will ignore parameters that are not writeable.
For Add, unless otherwise specified, all fields are writeable. For
SetInfo, each call explicitly lists the settable fields.
Note also that requesting certain levels of information is
pointless. Many times the level-0 information wil be the same as
what you pass to the GetInfo API to get the info. Most level-0
structures are provided for use with Enum calls.
1.5.04 Fixed-Length and Variable-Length Data
All calls that take data structures do so via a buffer pointer and
length, where the structure is contained at the start of the
specified buffer. Although each resource structure has a fixed
format, some parameters are pointers to variable length strings. When
such parameters are present on Add and SetInfo calls, it is desirable
for the caller to provide a buffer large enough for both the fixed
size structure and the variable length information (e.g., ASCIZ
strings). This is allows the API to optimize processing if the call
is to a remote host. Null pointers may be specified for variable
length parameters that are not supplied.
Note that because a buffer length is specified, result parameters are
provided on API calls to indicate how much data was available if the
supplied buffer was too small. Where a variable-length item could not
fit in the buffer, its pointer is set to NULL.
NOTE: None of the API calls will return partial fixed-data
structures. If GetInfo is passed a buffer too small to contain the
fixed structure, it will return an error code NERR_BuffTooSmall.
Enum will stop stuffing items in the buffer when it cannot fit the
fixed portion completely. Given a buffer which will hold the fixed
struct, both types of routines will happily stuff as much variable
data as will fit after the fixed stuff.
EXCEPTION: The NetStatisticsGet API will return as much of the
structure as will fit into the buffer. This API treats the data as
an array of longs (DWORDs), even though the header file and reference
define this data as a structure.
1.6 Return Values
All LAN Manager APIs return an unsigned int, which is 0 if they were
successful. Each function's documentation lists the error codes
which may be expected. This list is not guaranteed to be exhaustive,
but does list all errors an application should be prepared to handle
routinely and gracefully.
1.7 GetInfo Calls
GetInfo calls are used to get information on a specific instance of
something, such as a workstation, a connection, a user, etc.
The caller specifies what level of information is desired,
a "key" designating the resource of interest, a buffer
for the returned data, and the size of that buffer.
If a call to GetInfo provides a buffer too small to hold the
fixed portion of the data, the API returns NERR_BufTooSmall,
and no information is placed in the caller's buffer. However, the
total amout of data available, in bytes, is placed at the location
pointed to by the "totavail" parameter. It is quite valid to
call the API with a buffer of zero bytes (buffer may be NULL).
If the error returned is NERR_BufTooSmall, allocate a buffer using
the number of bytes from "totavail" and call the API with this
new buffer and size.
If the buffer is big enough for the fixed-length data, but not
for ALL of the data, the API function will return ERROR_MORE_DATA.
In this case, the buffer contains the data structure expected,
but some of the pointer fields may be NULL. See "Variable-Length
Data", above. As for NERR_BufTooSmall, the "totavail" field gives
and indication of the amount of data available and thus the buffer
size needed.
Totavail is NOT filled in if the API encounters an error during
processing, so the totavail value returned is valid only if the call
returns one of:
0
ERROR_MORE_DATA
NERR_BufTooSmall
1.8 Enum Calls
Enum calls enumerate a list of items within a given domain, such
as all servers on a network, all users on a system, all connections
to a given server, etc.
Enum calls will always return an integral number (zero or more) of
fixed length structures. API functions never return partial
structures.
The fixed structures returned will start at the low address of the
buffer and be packed contiguously into the buffer. Variable-length
data (see above) will be packed somehwere past the last fixed
structure. Usually this starts at the high address of the buffer
and works downward, but do not rely on this -- use the pointers in
the fixed structures to refer to variable-length data fields.
If the user buffer is not large enough, some of the variable length
data may not be returned, possibly only for the last entry but not
necessarily. The return code is ERROR_MORE_DATA whenever the
user-supplied buffer is not large enough to hold all entries,
including all variable-length data. The "entriesread" parameter
indicates the number of fixed length portions that were returned.
Some or all of these may have only a part of the associated variable
data returned with them. If a given varlen value has NOT been
returned, its pointer will be returned as NULL in the fixed length
structure.
Enum calls usually return both the number of entries read and the
number of entries available. Entries available is the total number
that could be retrieved and is always equal to or greater than the
number of entries read. These values are valid after a call which
returns either ERROR_MORE_DATA or success (zero).
All Enum calls can be called with a buflen of zero and a NULL
pointer. You won't get any data, but you will learn the total number
of entries available, as noted above.
1.9 SetInfo Calls
SetInfo calls are used to set one or more fields of an item.
The easiest way to set a single field is to use the "parmnum"
parameter to indicate which field to set, and pass the value directly
in the buffer. For example, to set the workstation's error-log file
size limit to 200K, use the following code fragment:
unsigned short errsize = 200;
NetWkstaSetInfo (
NULL, /* Local machine */
0, /* Level, must be zero for wksta */
&errsize, /* Buffer */
sizeof(errsize), /* Buffer size */
WKSTA_ERRLOGSZ_PARMNUM /* parmnum, from wksta.h */
);
Note that in this case the buffer is only two bytes, and consists
only of the value being set. For a string parameter, the buffer is
the string itself, and the size must include the NUL terminator. DO
NOT pass pointers when using the single-field mode. Pass the ASCIZ
string itself as the buffer. Example:
static char comment[] = "New comment here";
int clen;
clen = sizeof(comment);
<or>
clen = strlen(comment) + 1;
NetServerSetInfo (
NULL, /* Local machine */
0, /* Level, not used for single-field */
comment, /* Buffer */
clen, /* Buffer length */
SV_COMMENT_PARMNUM /* parmnum, from server.h */
);
To set multiple fields, either make multiple calls using the
"parmnum", or set the entire structure at once. In this case, the
buffer is a structure of the proper format, and parmnum is zero.
When setting the whole structure, fields that are not settable are
ignored. If a string is settable, but the pointer is set to NULL, it
is left unchanged. To set a string to the empty string, use a
pointer to the empty string.
NOTE: When setting the whole structure, ALWAYS do a GetInfo into the
buffer, change the fields, and then do a SetInfo. Do this even if
you think you are placing values in all settable fields. This will
protect you from future changes, which might define more fields as
settable. If you do a SetInfo without a prior GetInfo, you could
end up with garbage in those fields, or have your call rejected with
the error ERROR_INVALID_PARAMETER.
Example: suppose we wanted to make user "Fred" an administrator, and
set his comment to reflect that status.
struct user_info_1 ubuf;
unsigned err;
err = NetUserGetInfo ( NULL, "Fred", 1, &ubuf, sizeof(ubuf), &avail );
if (err == 0 || err == ERROR_MORE_DATA)
{
ubuf.usri1_priv = USER_PRIV_ADMIN;
ubuf.usri1_comment = "Newly promoted admininstrator";
NetUserSetInfo ( NULL, "Fred", 1, &ubuf, sizeof(ubuf), 0 );
}
1.10 Time Stamps
All absolute date/time parameters are in seconds since Jan 1, 1970.
Date/time is returned as local time relative to the caller of the
api. A future release of LAN Manager will do automatic date/time
zone conversion to local time if the target of the api is in a
different time zone.
1.11 Calling Lan Manager APIs
The APIs for Lan Manager for OS/2 are very similar to the OS/2
API functions.
o All API calls are far.
o All API parameters are pushed on the stack, in the order they
are declared, before the far call is made.
o The API function itself will remove the parameters from the stack
as part of the return to the caller.
1.11.01 Calling APIs from Microsoft C
C programs that call Lan Manager API functions should include the
proper header files, as noted in each API's reference section.
These header files provide #define's for various values used with
the APIs, and complete function prototypes.
If you do not use the function prototypes (we suggest you do),
be sure to at least declare the API functions as "extern unsigned
far pascal". The "pascal" keyword is essential and causes the compiler
to generate the proper calling sequence, defined above.
1.11.02 Calling APIs from Assembly Language
As noted above, all calls are far, and parameters are pushed on the
stack. The first parameter is pushed first. When the API function
returns, the stack pointer will have been adjusted so that the parameters
have been removed from the stack. This is the "pascal" or "PLM"
calling convention.
Return values are all in AX. All API functions return a WORD-sized
value which is the success or error code.
Make no assumptions about preservation of registers across a call to
the API functions, except that DS,SS will be preserved, SP will be
adjusted as above, and of course CS:IP will be the value pushed
on the stack during the CALL.
Function names should be given in all uppercase, for example,
NETWKSTAGETINFO.
Assembly language programmers may make the following assumptions
about data sizes:
char BYTE
unsigned char BYTE
short WORD
unsigned short WORD
long DWORD
unsigned long DWORD
unsigned currently WORD
1.11.03 Linking to the API Libraries
SInce the Lan Manager APIs are stored in a set of DLLs
(dynamic link libraries), applications may use any of the
methods defined for linking to these libraries.
The most convenient way is to link to the .LIB files provided.
These files cause the MS Link program to resolve references
to Lan Manager API functions properly, by providing information
about the name and entrypoint ordinal of the DLL.
The following library files are provided:
NETAPI.LIB Net API functions
NETOEM.LIB Net API functions
NETSPOOL.LIB DosPrint API functions
NAMPIPES.LIB DosNmPipe API functions
MAILSLOT.LIB DosMailslot API functions
1.12 Protection Violations and Faults in the DLL
The API functions probe the buffers passed to them and scan string
parameters in an attempt to insure that the data is accessable.
These probings may cause faults if the pointers are bad, such as
pointing beyond the end of a segment, or when a pointer is NULL and a
NULL pointer is not allowed.
If you get a fault within a Lan Manager DLL, attempt to trace your
code through the call. You can usually recognize, by noting which
values are being tested, exactly which parameter is causing the
problem. Carefully check buffer sizes, since the APIs will probe the
first and last byte of a buffer even if the actual data to be
returned or recieved is small.
If you get a stack overflow, extend your stack. There is no hard
rule for the depth of stack required by Lan Manager APIs in this
release. In general, allow 2K free stack space for an API call. This
should be quite safe, even if the thread in question will be
interrupted by signals.
1.13 General Error Codes
The error codes described here are nearly universal throughout the
Lan Manager APIs. These error codes can be found in either "neterr.h"
or the standard OS/2 error header files, which were called "error.h"
and "error2.h" in the OS/2 SDK.
o ERROR_MORE_DATA
This error is returned when the buffer supplied to the API is not big
enough to hold all the data available. As much data as possible has
been returned in this buffer. Some indication of the amount of data
has been returned, usually in the form of a pointer-to-value
parameter. More information is available above, under the general
information on Enum and GetInfo APIs.
To get the rest of the data, you can allocate a bigger buffer and try
the call again. If the data you need is in the buffer, there is no
need to retry.
o ERROR_INVALID_LEVEL
For APIs which take a "level" parameter, there is a defined set of
values which are acceptable. Note that for some APIs, even though
there may be multiple levels of data defined, only one level may be
acceptable. For example, NetShareAdd requires level 2 share data.
This error is returned in all cases where the value of level was not
acceptable.
o NERR_BufTooSmall
This error is returned when the buffer supplied to the API is not big
enough to the hold data, either input or output. In this case, NO
DATA is returned in the buffer, in contrast to ERROR_MORE_DATA, which
indicates that some, though not all, of the data was returned.
Allocate a bigger buffer (using the value returned in the
"totalavail" parameter, if such is provided) and try again.
o ERROR_INVALID_PARAMETER
This is a generic error which indicates a parameter is invalid. Each
API's documentation will give some hints as to which parameters could
cause this error to be returned. In general, parameters to check
include
SetInfo: Parmnum parameter.
The value(s) you are trying to set.
Add: Any field used by the API. Be sure you
have filled in all required values.
o NERR_NetNotStarted
Despite the name, this error really means that the network software
is not INSTALLED. That is, the core drivers were not loaded at boot
time. Almost no APIs will work without these drivers installed.
o NERR_WkstaNotStarted
The network software is installed, but the workstation is not
running. To start the workstation at the command line, type "NET
START WKSTA". Or, use the NetServiceInstall API. A few APIs will
work even with the workstation not running, and so will not return
this error.
o NERR_ServerNotStarted
The network software is installed, but the server is not running. To
start the server at the command line, type "NET START SERVER". Or,
use the NetServiceInstall API. Note that before you can start the
server, the workstation service must be running. The Lan Manager
command-line interface handles this automatically.
o NERR_ACFNotLoaded
This API requires that a user-level security server be running.
o NERR_BadTransactConfig
The remote station is not configured for remote transactions.
Usually this means the server you are attempting to access with a
remote API is not sharing IPC$. A server must share IPC$ to allow
other machines to submit remote API calls to it.
o ERROR_NETWORK_ACCESS_DENIED
This error is the generic "security violation" error, and indicates
that the operation failed due to insufficient privilege.
2. SHARES
These functions deal with resource sharing at a server.
All of these functions should be used with the include file "shares.h".
The access bits are defined in "access.h".
There are three levels of information available:
struct share_info_0 {
char shi0_netname[NNLEN+1];
};
struct share_info_1 {
char shi1_netname[NNLEN+1];
char shi1_pad1;
unsigned short shi1_type;
char far * shi1_remark;
};
struct share_info_2 {
char shi2_netname[NNLEN+1];
char shi2_pad1;
unsigned short shi2_type;
char far * shi2_remark;
unsigned short shi2_permissions;
unsigned short shi2_max_uses;
unsigned short shi2_current_uses;
char far * shi2_path;
char shi2_passwd[SHPWLEN+1];
char shi2_pad2;
};
netname The netname is the name by which a share is exported
to the network. This name may be between 1 and NNLEN
characters long.
Only standard file-system component characters are allowed.
type Type of resource being shared, may be one of:
STYPE_DISKTREE 0 File system share
STYPE_PRINTQ 1 Spooled print queue
STYPE_DEVICE 2 Character device queue
STYPE_IPC 3 Special IPC share
remark Remark or comment describing a share (optional).
An ASCIZ string which provides information about a share,
visible to users on the network.
permissions Share-level permissions, bitmapped usinjg the same
values as given under the Access APIs.
0 ACCESS_READ 0x1 Read from existing resources
1 ACCESS_WRITE 0x2 Write to existing resources
2 ACCESS_CREATE 0x4 Create new files
3 ACCESS_EXEC 0x8 Open file for execution
4 ACCESS_DELETE 0x10 Delete existing files
5 ACCESS_ATRIB 0x20 Set the resource's attribute,
6 ACCESS_PERM 0x40 Special, see below
The ACCESS_PERM bit has special meaning for shares.
If this bit is set, a user must have ADMIN rights
to connect to the share.
In share-level security, all bits above are used.
These access permissions apply to ALL access through
the given share. Note that a share with no permissions
is nearly worthless; you can connect to it but that is
all.
In user-level security, share-level permissions are INGORED.
Only the ACCESS_PERM bit, with the special meaning given
above, is used. All other bits are completely ignored,
and the normal user-level access permission system is