Lots of NetApi32 additions

pull/47/head
David Hall 2019-02-18 14:27:57 -07:00
parent 20adde08ae
commit af83c80249
15 changed files with 9915 additions and 376 deletions

View File

@ -1,19 +1,24 @@
## Correlation report for netapi32.dll
### Methods (14% complete)
### Methods (52% complete)
Native Method | Native DLL | Header | Managed Method
--- | --- | --- | ---
[DavAddConnection](https://www.google.com/search?num=5&q=DavAddConnection+site%3Amicrosoft.com) | netapi32.dll | |
[DavDeleteConnection](https://www.google.com/search?num=5&q=DavDeleteConnection+site%3Amicrosoft.com) | netapi32.dll | |
[DavFlushFile](https://www.google.com/search?num=5&q=DavFlushFile+site%3Amicrosoft.com) | netapi32.dll | |
[DavGetExtendedError](https://www.google.com/search?num=5&q=DavGetExtendedError+site%3Amicrosoft.com) | netapi32.dll | |
[DavGetHTTPFromUNCPath](https://www.google.com/search?num=5&q=DavGetHTTPFromUNCPath+site%3Amicrosoft.com) | netapi32.dll | |
[DavGetUNCFromHTTPPath](https://www.google.com/search?num=5&q=DavGetUNCFromHTTPPath+site%3Amicrosoft.com) | netapi32.dll | |
[DavAddConnection](http://msdn2.microsoft.com/en-us/library/d69cba04-503c-4d21-b762-3094c0921e28) | netapi32.dll | davclnt.h | Vanara.PInvoke.NetApi32.DavAddConnection
[DavCancelConnectionsToServer](http://msdn2.microsoft.com/en-us/library/6eb3b011-4cd3-45ec-a07e-c8743d35a176) | netapi32.dll | davclnt.h | Vanara.PInvoke.NetApi32.DavCancelConnectionsToServer
[DavDeleteConnection](http://msdn2.microsoft.com/en-us/library/736b8a16-30db-410e-8295-97730297d04b) | netapi32.dll | davclnt.h | Vanara.PInvoke.NetApi32.DavDeleteConnection
[DavFlushFile](http://msdn2.microsoft.com/en-us/library/0022a5ba-a4b2-4289-91be-db7f52e62f91) | netapi32.dll | davclnt.h | Vanara.PInvoke.NetApi32.DavFlushFile
[DavGetExtendedError](http://msdn2.microsoft.com/en-us/library/939b6163-b7ae-4ab7-9bcc-a02cbf34ca63) | netapi32.dll | davclnt.h | Vanara.PInvoke.NetApi32.DavGetExtendedError
[DavGetHTTPFromUNCPath](http://msdn2.microsoft.com/en-us/library/caa83e54-a029-45aa-9681-26b2be54fea3) | netapi32.dll | davclnt.h | Vanara.PInvoke.NetApi32.DavGetHTTPFromUNCPath
[DavGetTheLockOwnerOfTheFile](http://msdn2.microsoft.com/en-us/library/94a4607c-2770-4656-8710-987d6b951e0e) | netapi32.dll | davclnt.h | Vanara.PInvoke.NetApi32.DavGetTheLockOwnerOfTheFile
[DavGetUNCFromHTTPPath](http://msdn2.microsoft.com/en-us/library/e9613e4a-5ba1-4954-bc7a-7843249f031e) | netapi32.dll | davclnt.h | Vanara.PInvoke.NetApi32.DavGetUNCFromHTTPPath
[DavInvalidateCache](http://msdn2.microsoft.com/en-us/library/f111b19c-5472-463a-b33d-7d2188d224e8) | netapi32.dll | davclnt.h | Vanara.PInvoke.NetApi32.DavInvalidateCache
[DavRegisterAuthCallback](http://msdn2.microsoft.com/en-us/library/7b381929-174f-4b7b-aa22-dc7a2c3e3b4d) | netapi32.dll | davclnt.h | Vanara.PInvoke.NetApi32.DavRegisterAuthCallback
[DavUnregisterAuthCallback](http://msdn2.microsoft.com/en-us/library/5277d9ce-22e6-49d5-9a9c-c02993605bdf) | netapi32.dll | davclnt.h | Vanara.PInvoke.NetApi32.DavUnregisterAuthCallback
[DsAddressToSiteNames](http://msdn2.microsoft.com/en-us/library/4d70dbee-be33-4d2a-a200-3696443fa853) | netapi32.dll | dsgetdc.h | Vanara.PInvoke.NetApi32.DsAddressToSiteNames
[DsAddressToSiteNamesEx](http://msdn2.microsoft.com/en-us/library/60ac6195-6e43-46da-a1e6-74ec989cd0c4) | netapi32.dll | dsgetdc.h | Vanara.PInvoke.NetApi32.DsAddressToSiteNamesEx
[DsDeregisterDnsHostRecords](http://msdn2.microsoft.com/en-us/library/18ab6455-dab2-42d9-b68e-a8f0ad2d8091) | netapi32.dll | dsgetdc.h | Vanara.PInvoke.NetApi32.DsDeregisterDnsHostRecords
[DsEnumerateDomainTrusts](http://msdn2.microsoft.com/en-us/library/6c3b788f-ee53-4637-acdb-04316e8464fe) | netapi32.dll | dsgetdc.h | Vanara.PInvoke.NetApi32.DsEnumerateDomainTrusts
[DsGetDcCloseW](http://msdn2.microsoft.com/en-us/library/d193e4cd-ad66-4d93-b912-348f17e93a6f) | netapi32.dll | dsgetdc.h | Vanara.PInvoke.NetApi32.DsGetDcClose
[DsGetDcName](http://msdn2.microsoft.com/en-us/library/ms675983) | netapi32.dll | DsGetDC.h | Vanara.PInvoke.NetApi32.DsGetDcName
[DsGetDcName](http://msdn2.microsoft.com/en-us/library/da8b2983-5e45-40b0-b552-c9b3a1d8ae94) | netapi32.dll | dsgetdc.h | Vanara.PInvoke.NetApi32.DsGetDcName
[DsGetDcNext](http://msdn2.microsoft.com/en-us/library/2906772f-4391-411b-b0a9-5a20ebb6c0ee) | netapi32.dll | dsgetdc.h | Vanara.PInvoke.NetApi32.DsGetDcNext
[DsGetDcOpen](http://msdn2.microsoft.com/en-us/library/2811cc30-f367-4f1a-8f0c-ed0a77dad24c) | netapi32.dll | dsgetdc.h | Vanara.PInvoke.NetApi32.DsGetDcOpen
[DsGetDcSiteCoverage](http://msdn2.microsoft.com/en-us/library/e0f757d9-36b6-40f8-a1db-fb5b9862b46a) | netapi32.dll | dsgetdc.h | Vanara.PInvoke.NetApi32.DsGetDcSiteCoverage
@ -29,23 +34,17 @@ Native Method | Native DLL | Header | Managed Method
[NetAccessGetInfo](https://www.google.com/search?num=5&q=NetAccessGetInfo+site%3Amicrosoft.com) | netapi32.dll | |
[NetAccessGetUserPerms](https://www.google.com/search?num=5&q=NetAccessGetUserPerms+site%3Amicrosoft.com) | netapi32.dll | |
[NetAccessSetInfo](https://www.google.com/search?num=5&q=NetAccessSetInfo+site%3Amicrosoft.com) | netapi32.dll | |
[NetAddAlternateComputerName](https://www.google.com/search?num=5&q=NetAddAlternateComputerName+site%3Amicrosoft.com) | netapi32.dll | |
[NetAddAlternateComputerName](http://msdn2.microsoft.com/en-us/library/710865c6-e327-439c-931d-de8674d69233) | netapi32.dll | lmjoin.h | Vanara.PInvoke.NetApi32.NetAddAlternateComputerName
[NetAddServiceAccount](https://www.google.com/search?num=5&q=NetAddServiceAccount+site%3Amicrosoft.com) | netapi32.dll | |
[NetAlertRaise](https://www.google.com/search?num=5&q=NetAlertRaise+site%3Amicrosoft.com) | netapi32.dll | |
[NetAlertRaiseEx](https://www.google.com/search?num=5&q=NetAlertRaiseEx+site%3Amicrosoft.com) | netapi32.dll | |
[NetApiBufferAllocate](https://www.google.com/search?num=5&q=NetApiBufferAllocate+site%3Amicrosoft.com) | netapi32.dll | |
[NetAlertRaise](http://msdn2.microsoft.com/en-us/library/11367a72-c21d-4044-98cf-a7a30cc43a8b) | netapi32.dll | lmalert.h | Vanara.PInvoke.NetApi32.NetAlertRaise
[NetAlertRaiseEx](http://msdn2.microsoft.com/en-us/library/9762f0d6-0022-4e05-b2d8-6223d7bbb2c8) | netapi32.dll | lmalert.h | Vanara.PInvoke.NetApi32.NetAlertRaiseEx
[NetApiBufferAllocate](http://msdn2.microsoft.com/en-us/library/9ff1e3eb-9417-469f-a8c0-cdcda3cd9583) | netapi32.dll | lmapibuf.h | Vanara.PInvoke.NetApi32.NetApiBufferAllocate
[NetApiBufferFree](http://msdn2.microsoft.com/en-us/library/aa370304) | netapi32.dll | lm.h | Vanara.PInvoke.NetApi32.NetApiBufferFree
[NetApiBufferReallocate](https://www.google.com/search?num=5&q=NetApiBufferReallocate+site%3Amicrosoft.com) | netapi32.dll | |
[NetApiBufferSize](https://www.google.com/search?num=5&q=NetApiBufferSize+site%3Amicrosoft.com) | netapi32.dll | |
[NetAuditClear](https://www.google.com/search?num=5&q=NetAuditClear+site%3Amicrosoft.com) | netapi32.dll | |
[NetAuditRead](https://www.google.com/search?num=5&q=NetAuditRead+site%3Amicrosoft.com) | netapi32.dll | |
[NetAuditWrite](https://www.google.com/search?num=5&q=NetAuditWrite+site%3Amicrosoft.com) | netapi32.dll | |
[NetApiBufferReallocate](http://msdn2.microsoft.com/en-us/library/61153de0-33d3-4c83-a8aa-a7179252328c) | netapi32.dll | lmapibuf.h | Vanara.PInvoke.NetApi32.NetApiBufferReallocate
[NetApiBufferSize](http://msdn2.microsoft.com/en-us/library/0c28feeb-00a3-4ad5-b85f-96326515fae2) | netapi32.dll | lmapibuf.h | Vanara.PInvoke.NetApi32.NetApiBufferSize
[Netbios](https://www.google.com/search?num=5&q=Netbios+site%3Amicrosoft.com) | netapi32.dll | |
[NetConfigGet](https://www.google.com/search?num=5&q=NetConfigGet+site%3Amicrosoft.com) | netapi32.dll | |
[NetConfigGetAll](https://www.google.com/search?num=5&q=NetConfigGetAll+site%3Amicrosoft.com) | netapi32.dll | |
[NetConfigSet](https://www.google.com/search?num=5&q=NetConfigSet+site%3Amicrosoft.com) | netapi32.dll | |
[NetConnectionEnum](https://www.google.com/search?num=5&q=NetConnectionEnum+site%3Amicrosoft.com) | netapi32.dll | |
[NetCreateProvisioningPackage](https://www.google.com/search?num=5&q=NetCreateProvisioningPackage+site%3Amicrosoft.com) | netapi32.dll | |
[NetConnectionEnum](http://msdn2.microsoft.com/en-us/library/935ac6e9-78e0-42ae-a454-0a14b03ddc21) | netapi32.dll | lmshare.h | Vanara.PInvoke.NetApi32.NetConnectionEnum
[NetCreateProvisioningPackage](http://msdn2.microsoft.com/en-us/library/6E2A5578-8308-41E2-B5E9-5E34E9E76C0B) | netapi32.dll | lmjoin.h | Vanara.PInvoke.NetApi32.NetCreateProvisioningPackage
[NetDfsAdd](https://www.google.com/search?num=5&q=NetDfsAdd+site%3Amicrosoft.com) | netapi32.dll | |
[NetDfsAddFtRoot](https://www.google.com/search?num=5&q=NetDfsAddFtRoot+site%3Amicrosoft.com) | netapi32.dll | |
[NetDfsAddRootTarget](https://www.google.com/search?num=5&q=NetDfsAddRootTarget+site%3Amicrosoft.com) | netapi32.dll | |
@ -69,21 +68,18 @@ Native Method | Native DLL | Header | Managed Method
[NetDfsSetInfo](https://www.google.com/search?num=5&q=NetDfsSetInfo+site%3Amicrosoft.com) | netapi32.dll | |
[NetDfsSetSecurity](https://www.google.com/search?num=5&q=NetDfsSetSecurity+site%3Amicrosoft.com) | netapi32.dll | |
[NetDfsSetStdContainerSecurity](https://www.google.com/search?num=5&q=NetDfsSetStdContainerSecurity+site%3Amicrosoft.com) | netapi32.dll | |
[NetEnumerateComputerNames](https://www.google.com/search?num=5&q=NetEnumerateComputerNames+site%3Amicrosoft.com) | netapi32.dll | |
[NetEnumerateComputerNames](http://msdn2.microsoft.com/en-us/library/c657ae33-404e-4c36-a956-5fbcfa540be7) | netapi32.dll | lmjoin.h | Vanara.PInvoke.NetApi32.NetEnumerateComputerNames
[NetEnumerateServiceAccounts](https://www.google.com/search?num=5&q=NetEnumerateServiceAccounts+site%3Amicrosoft.com) | netapi32.dll | |
[NetErrorLogClear](https://www.google.com/search?num=5&q=NetErrorLogClear+site%3Amicrosoft.com) | netapi32.dll | |
[NetErrorLogRead](https://www.google.com/search?num=5&q=NetErrorLogRead+site%3Amicrosoft.com) | netapi32.dll | |
[NetErrorLogWrite](https://www.google.com/search?num=5&q=NetErrorLogWrite+site%3Amicrosoft.com) | netapi32.dll | |
[NetFileClose](https://www.google.com/search?num=5&q=NetFileClose+site%3Amicrosoft.com) | netapi32.dll | |
[NetFileEnum](https://www.google.com/search?num=5&q=NetFileEnum+site%3Amicrosoft.com) | netapi32.dll | |
[NetFileGetInfo](https://www.google.com/search?num=5&q=NetFileGetInfo+site%3Amicrosoft.com) | netapi32.dll | |
[NetFreeAadJoinInformation](https://www.google.com/search?num=5&q=NetFreeAadJoinInformation+site%3Amicrosoft.com) | netapi32.dll | |
[NetGetAadJoinInformation](https://www.google.com/search?num=5&q=NetGetAadJoinInformation+site%3Amicrosoft.com) | netapi32.dll | |
[NetFileClose](http://msdn2.microsoft.com/en-us/library/36a5f464-fec3-4b4f-91c3-447ff5ff70af) | netapi32.dll | lmshare.h | Vanara.PInvoke.NetApi32.NetFileClose
[NetFileEnum](http://msdn2.microsoft.com/en-us/library/1375b337-efb0-4be1-94f7-473456a825b5) | netapi32.dll | lmshare.h | Vanara.PInvoke.NetApi32.NetFileEnum
[NetFileGetInfo](http://msdn2.microsoft.com/en-us/library/d50c05e7-7ddd-4a7d-96f6-51878e52373c) | netapi32.dll | lmshare.h | Vanara.PInvoke.NetApi32.NetFileGetInfo
[NetFreeAadJoinInformation](http://msdn2.microsoft.com/en-us/library/BDFB6179-4B8C-43E3-8D34-A2B470EA0D0B) | netapi32.dll | lmjoin.h | Vanara.PInvoke.NetApi32.NetFreeAadJoinInformation
[NetGetAadJoinInformation](http://msdn2.microsoft.com/en-us/library/C63B3AA7-FC7E-4CB9-9318-BD25560591AB) | netapi32.dll | lmjoin.h | Vanara.PInvoke.NetApi32.NetGetAadJoinInformation
[NetGetAnyDCName](https://www.google.com/search?num=5&q=NetGetAnyDCName+site%3Amicrosoft.com) | netapi32.dll | |
[NetGetDCName](https://www.google.com/search?num=5&q=NetGetDCName+site%3Amicrosoft.com) | netapi32.dll | |
[NetGetDisplayInformationIndex](https://www.google.com/search?num=5&q=NetGetDisplayInformationIndex+site%3Amicrosoft.com) | netapi32.dll | |
[NetGetJoinableOUs](https://www.google.com/search?num=5&q=NetGetJoinableOUs+site%3Amicrosoft.com) | netapi32.dll | |
[NetGetJoinInformation](https://www.google.com/search?num=5&q=NetGetJoinInformation+site%3Amicrosoft.com) | netapi32.dll | |
[NetGetJoinableOUs](http://msdn2.microsoft.com/en-us/library/1faa912b-c56d-431c-95d5-d36790b0d467) | netapi32.dll | lmjoin.h | Vanara.PInvoke.NetApi32.NetGetJoinableOUs
[NetGetJoinInformation](http://msdn2.microsoft.com/en-us/library/c7cc1cf2-4530-4039-806b-fbee572f564d) | netapi32.dll | lmjoin.h | Vanara.PInvoke.NetApi32.NetGetJoinInformation
[NetGroupAdd](https://www.google.com/search?num=5&q=NetGroupAdd+site%3Amicrosoft.com) | netapi32.dll | |
[NetGroupAddUser](https://www.google.com/search?num=5&q=NetGroupAddUser+site%3Amicrosoft.com) | netapi32.dll | |
[NetGroupDel](https://www.google.com/search?num=5&q=NetGroupDel+site%3Amicrosoft.com) | netapi32.dll | |
@ -94,7 +90,7 @@ Native Method | Native DLL | Header | Managed Method
[NetGroupSetInfo](https://www.google.com/search?num=5&q=NetGroupSetInfo+site%3Amicrosoft.com) | netapi32.dll | |
[NetGroupSetUsers](https://www.google.com/search?num=5&q=NetGroupSetUsers+site%3Amicrosoft.com) | netapi32.dll | |
[NetIsServiceAccount](https://www.google.com/search?num=5&q=NetIsServiceAccount+site%3Amicrosoft.com) | netapi32.dll | |
[NetJoinDomain](https://www.google.com/search?num=5&q=NetJoinDomain+site%3Amicrosoft.com) | netapi32.dll | |
[NetJoinDomain](http://msdn2.microsoft.com/en-us/library/4efcb399-03af-4312-9f1d-6bc38f356cac) | netapi32.dll | lmjoin.h | Vanara.PInvoke.NetApi32.NetJoinDomain
[NetLocalGroupAdd](https://www.google.com/search?num=5&q=NetLocalGroupAdd+site%3Amicrosoft.com) | netapi32.dll | |
[NetLocalGroupAddMember](https://www.google.com/search?num=5&q=NetLocalGroupAddMember+site%3Amicrosoft.com) | netapi32.dll | |
[NetLocalGroupAddMembers](https://www.google.com/search?num=5&q=NetLocalGroupAddMembers+site%3Amicrosoft.com) | netapi32.dll | |
@ -106,21 +102,16 @@ Native Method | Native DLL | Header | Managed Method
[NetLocalGroupGetMembers](https://www.google.com/search?num=5&q=NetLocalGroupGetMembers+site%3Amicrosoft.com) | netapi32.dll | |
[NetLocalGroupSetInfo](https://www.google.com/search?num=5&q=NetLocalGroupSetInfo+site%3Amicrosoft.com) | netapi32.dll | |
[NetLocalGroupSetMembers](https://www.google.com/search?num=5&q=NetLocalGroupSetMembers+site%3Amicrosoft.com) | netapi32.dll | |
[NetMessageBufferSend](https://www.google.com/search?num=5&q=NetMessageBufferSend+site%3Amicrosoft.com) | netapi32.dll | |
[NetMessageNameAdd](https://www.google.com/search?num=5&q=NetMessageNameAdd+site%3Amicrosoft.com) | netapi32.dll | |
[NetMessageNameDel](https://www.google.com/search?num=5&q=NetMessageNameDel+site%3Amicrosoft.com) | netapi32.dll | |
[NetMessageNameEnum](https://www.google.com/search?num=5&q=NetMessageNameEnum+site%3Amicrosoft.com) | netapi32.dll | |
[NetMessageNameGetInfo](https://www.google.com/search?num=5&q=NetMessageNameGetInfo+site%3Amicrosoft.com) | netapi32.dll | |
[NetProvisionComputerAccount](https://www.google.com/search?num=5&q=NetProvisionComputerAccount+site%3Amicrosoft.com) | netapi32.dll | |
[NetProvisionComputerAccount](http://msdn2.microsoft.com/en-us/library/4c854258-b84d-4ef3-a6da-ce0a9540ffd5) | netapi32.dll | lmjoin.h | Vanara.PInvoke.NetApi32.NetProvisionComputerAccount
[NetQueryDisplayInformation](https://www.google.com/search?num=5&q=NetQueryDisplayInformation+site%3Amicrosoft.com) | netapi32.dll | |
[NetQueryServiceAccount](https://www.google.com/search?num=5&q=NetQueryServiceAccount+site%3Amicrosoft.com) | netapi32.dll | |
[NetRemoteComputerSupports](https://www.google.com/search?num=5&q=NetRemoteComputerSupports+site%3Amicrosoft.com) | netapi32.dll | |
[NetRemoteTOD](https://www.google.com/search?num=5&q=NetRemoteTOD+site%3Amicrosoft.com) | netapi32.dll | |
[NetRemoveAlternateComputerName](https://www.google.com/search?num=5&q=NetRemoveAlternateComputerName+site%3Amicrosoft.com) | netapi32.dll | |
[NetRemoteComputerSupports](http://msdn2.microsoft.com/en-us/library/e807489a-250e-4d4c-adb6-eff8ac30603b) | netapi32.dll | lmremutl.h | Vanara.PInvoke.NetApi32.NetRemoteComputerSupports
[NetRemoteTOD](http://msdn2.microsoft.com/en-us/library/5a935e09-f188-4ee1-b998-c67488475baa) | netapi32.dll | lmremutl.h | Vanara.PInvoke.NetApi32.NetRemoteTOD
[NetRemoveAlternateComputerName](http://msdn2.microsoft.com/en-us/library/3c7ab44e-d5fa-40da-83fe-a44bf85b2ba5) | netapi32.dll | lmjoin.h | Vanara.PInvoke.NetApi32.NetRemoveAlternateComputerName
[NetRemoveServiceAccount](https://www.google.com/search?num=5&q=NetRemoveServiceAccount+site%3Amicrosoft.com) | netapi32.dll | |
[NetRenameMachineInDomain](https://www.google.com/search?num=5&q=NetRenameMachineInDomain+site%3Amicrosoft.com) | netapi32.dll | |
[NetRequestOfflineDomainJoin](https://www.google.com/search?num=5&q=NetRequestOfflineDomainJoin+site%3Amicrosoft.com) | netapi32.dll | |
[NetRequestProvisioningPackageInstall](https://www.google.com/search?num=5&q=NetRequestProvisioningPackageInstall+site%3Amicrosoft.com) | netapi32.dll | |
[NetRenameMachineInDomain](http://msdn2.microsoft.com/en-us/library/1f7ddaa1-a349-49a6-856d-a2fde2f1dc3b) | netapi32.dll | lmjoin.h | Vanara.PInvoke.NetApi32.NetRenameMachineInDomain
[NetRequestOfflineDomainJoin](http://msdn2.microsoft.com/en-us/library/f3f8fe00-d6f7-4d59-a4e7-6aef7f507e1a) | netapi32.dll | lmjoin.h | Vanara.PInvoke.NetApi32.NetRequestOfflineDomainJoin
[NetRequestProvisioningPackageInstall](http://msdn2.microsoft.com/en-us/library/107ED0F7-8DDD-4C18-8C34-3A67F771FA62) | netapi32.dll | lmjoin.h | Vanara.PInvoke.NetApi32.NetRequestProvisioningPackageInstall
[NetScheduleJobAdd](https://www.google.com/search?num=5&q=NetScheduleJobAdd+site%3Amicrosoft.com) | netapi32.dll | |
[NetScheduleJobDel](https://www.google.com/search?num=5&q=NetScheduleJobDel+site%3Amicrosoft.com) | netapi32.dll | |
[NetScheduleJobEnum](https://www.google.com/search?num=5&q=NetScheduleJobEnum+site%3Amicrosoft.com) | netapi32.dll | |
@ -128,34 +119,30 @@ Native Method | Native DLL | Header | Managed Method
[NetServerComputerNameAdd](http://msdn2.microsoft.com/en-us/library/0789fbfe-be91-4849-a31c-1e1a6ae1e70d) | netapi32.dll | lmserver.h | Vanara.PInvoke.NetApi32.NetServerComputerNameAdd
[NetServerComputerNameDel](http://msdn2.microsoft.com/en-us/library/501232ad-2821-4bbd-9f16-0f49984f6101) | netapi32.dll | lmserver.h | Vanara.PInvoke.NetApi32.NetServerComputerNameDel
[NetServerDiskEnum](http://msdn2.microsoft.com/en-us/library/56c981f4-7a1d-4465-bd7b-5996222c4210) | netapi32.dll | lmserver.h | Vanara.PInvoke.NetApi32.NetServerDiskEnum
[NetServerEnum](http://msdn2.microsoft.com/en-us/library/aa370623) | netapi32.dll | lm.h | Vanara.PInvoke.NetApi32.NetServerEnum
[NetServerGetInfo](http://msdn2.microsoft.com/en-us/library/aa370624) | netapi32.dll | lm.h | Vanara.PInvoke.NetApi32.NetServerGetInfo
[NetServerEnum](http://msdn2.microsoft.com/en-us/library/10012a87-805e-4817-9f09-9e5632b1fa09) | netapi32.dll | lmserver.h | Vanara.PInvoke.NetApi32.NetServerEnum
[NetServerGetInfo](http://msdn2.microsoft.com/en-us/library/aa370624) | netapi32.dll | lmserver.h | Vanara.PInvoke.NetApi32.NetServerGetInfo
[NetServerSetInfo](http://msdn2.microsoft.com/en-us/library/1a04a43d-34f9-4a08-ac66-750120792af0) | netapi32.dll | lmserver.h | Vanara.PInvoke.NetApi32.NetServerSetInfo
[NetServerTransportAdd](http://msdn2.microsoft.com/en-us/library/c8521aed-0762-4412-b117-c911fc77049b) | netapi32.dll | lmserver.h | Vanara.PInvoke.NetApi32.NetServerTransportAdd
[NetServerTransportAddEx](http://msdn2.microsoft.com/en-us/library/d1edc75d-8313-422c-a6fb-8b51a309a252) | netapi32.dll | lmserver.h | Vanara.PInvoke.NetApi32.NetServerTransportAddEx
[NetServerTransportDel](http://msdn2.microsoft.com/en-us/library/69b22f30-62b1-4dcb-bbb0-aceae8d77f61) | netapi32.dll | lmserver.h | Vanara.PInvoke.NetApi32.NetServerTransportDel
[NetServerTransportEnum](http://msdn2.microsoft.com/en-us/library/db42ac44-d70d-4b89-882a-6ac83fd611fd) | netapi32.dll | lmserver.h | Vanara.PInvoke.NetApi32.NetServerTransportEnum
[NetServiceControl](https://www.google.com/search?num=5&q=NetServiceControl+site%3Amicrosoft.com) | netapi32.dll | |
[NetServiceEnum](https://www.google.com/search?num=5&q=NetServiceEnum+site%3Amicrosoft.com) | netapi32.dll | |
[NetServiceGetInfo](https://www.google.com/search?num=5&q=NetServiceGetInfo+site%3Amicrosoft.com) | netapi32.dll | |
[NetServiceInstall](https://www.google.com/search?num=5&q=NetServiceInstall+site%3Amicrosoft.com) | netapi32.dll | |
[NetSessionDel](https://www.google.com/search?num=5&q=NetSessionDel+site%3Amicrosoft.com) | netapi32.dll | |
[NetSessionEnum](https://www.google.com/search?num=5&q=NetSessionEnum+site%3Amicrosoft.com) | netapi32.dll | |
[NetSessionGetInfo](https://www.google.com/search?num=5&q=NetSessionGetInfo+site%3Amicrosoft.com) | netapi32.dll | |
[NetSetPrimaryComputerName](https://www.google.com/search?num=5&q=NetSetPrimaryComputerName+site%3Amicrosoft.com) | netapi32.dll | |
[NetShareAdd](https://www.google.com/search?num=5&q=NetShareAdd+site%3Amicrosoft.com) | netapi32.dll | |
[NetShareCheck](https://www.google.com/search?num=5&q=NetShareCheck+site%3Amicrosoft.com) | netapi32.dll | |
[NetShareDel](https://www.google.com/search?num=5&q=NetShareDel+site%3Amicrosoft.com) | netapi32.dll | |
[NetShareDelEx](https://www.google.com/search?num=5&q=NetShareDelEx+site%3Amicrosoft.com) | netapi32.dll | |
[NetShareEnum](https://www.google.com/search?num=5&q=NetShareEnum+site%3Amicrosoft.com) | netapi32.dll | |
[NetShareGetInfo](https://www.google.com/search?num=5&q=NetShareGetInfo+site%3Amicrosoft.com) | netapi32.dll | |
[NetShareSetInfo](https://www.google.com/search?num=5&q=NetShareSetInfo+site%3Amicrosoft.com) | netapi32.dll | |
[NetSessionDel](http://msdn2.microsoft.com/en-us/library/a1360f5d-9fd0-44af-b9f5-ab9bc057dfe6) | netapi32.dll | lmshare.h | Vanara.PInvoke.NetApi32.NetSessionDel
[NetSessionEnum](http://msdn2.microsoft.com/en-us/library/5923a8cc-bf7a-4ffa-b089-fd7f26ee42d2) | netapi32.dll | lmshare.h | Vanara.PInvoke.NetApi32.NetSessionEnum
[NetSessionGetInfo](http://msdn2.microsoft.com/en-us/library/d44fb8d8-2b64-4268-8603-7784e2c5f2d5) | netapi32.dll | lmshare.h | Vanara.PInvoke.NetApi32.NetSessionGetInfo
[NetSetPrimaryComputerName](http://msdn2.microsoft.com/en-us/library/524c8219-a303-45ab-95e2-91319b477568) | netapi32.dll | lmjoin.h | Vanara.PInvoke.NetApi32.NetSetPrimaryComputerName
[NetShareAdd](http://msdn2.microsoft.com/en-us/library/8b51c155-24e8-4d39-b818-eb2d1bb0ee8b) | netapi32.dll | lmshare.h | Vanara.PInvoke.NetApi32.NetShareAdd
[NetShareCheck](http://msdn2.microsoft.com/en-us/library/8453dcd2-5c58-4fe4-9426-0fd51647394d) | netapi32.dll | lmshare.h | Vanara.PInvoke.NetApi32.NetShareCheck
[NetShareDel](http://msdn2.microsoft.com/en-us/library/374b8f81-b3d6-4967-bd4a-ffd3fdc3cf7c) | netapi32.dll | lmshare.h | Vanara.PInvoke.NetApi32.NetShareDel
[NetShareDelEx](http://msdn2.microsoft.com/en-us/library/2461c533-351b-48f4-b660-cb17ac3398fa) | netapi32.dll | lmshare.h | Vanara.PInvoke.NetApi32.NetShareDelEx
[NetShareEnum](http://msdn2.microsoft.com/en-us/library/9114c54d-3905-4d40-9162-b3ea605f6fcb) | netapi32.dll | lmshare.h | Vanara.PInvoke.NetApi32.NetShareEnum
[NetShareGetInfo](http://msdn2.microsoft.com/en-us/library/672ea208-4048-4d2f-9606-ee3e2133765b) | netapi32.dll | lmshare.h | Vanara.PInvoke.NetApi32.NetShareGetInfo
[NetShareSetInfo](http://msdn2.microsoft.com/en-us/library/216b0b78-87da-4734-ad07-5ad1c9edf494) | netapi32.dll | lmshare.h | Vanara.PInvoke.NetApi32.NetShareSetInfo
[NetStatisticsGet](https://www.google.com/search?num=5&q=NetStatisticsGet+site%3Amicrosoft.com) | netapi32.dll | |
[NetUnjoinDomain](https://www.google.com/search?num=5&q=NetUnjoinDomain+site%3Amicrosoft.com) | netapi32.dll | |
[NetUseAdd](https://www.google.com/search?num=5&q=NetUseAdd+site%3Amicrosoft.com) | netapi32.dll | |
[NetUseDel](https://www.google.com/search?num=5&q=NetUseDel+site%3Amicrosoft.com) | netapi32.dll | |
[NetUseEnum](https://www.google.com/search?num=5&q=NetUseEnum+site%3Amicrosoft.com) | netapi32.dll | |
[NetUseGetInfo](https://www.google.com/search?num=5&q=NetUseGetInfo+site%3Amicrosoft.com) | netapi32.dll | |
[NetUnjoinDomain](http://msdn2.microsoft.com/en-us/library/cc755c22-1fd6-4787-999e-a43258287a05) | netapi32.dll | lmjoin.h | Vanara.PInvoke.NetApi32.NetUnjoinDomain
[NetUseAdd](http://msdn2.microsoft.com/en-us/library/22550c17-003a-4f59-80f0-58fa3e286844) | netapi32.dll | lmuse.h | Vanara.PInvoke.NetApi32.NetUseAdd
[NetUseDel](http://msdn2.microsoft.com/en-us/library/200b0640-71e9-4f60-bf4c-c8df10bfe095) | netapi32.dll | lmuse.h | Vanara.PInvoke.NetApi32.NetUseDel
[NetUseEnum](http://msdn2.microsoft.com/en-us/library/fb527f85-baea-48e8-b837-967870834ec5) | netapi32.dll | lmuse.h | Vanara.PInvoke.NetApi32.NetUseEnum
[NetUseGetInfo](http://msdn2.microsoft.com/en-us/library/257875db-5ed9-4569-8dbb-5dcc7a6af95c) | netapi32.dll | lmuse.h | Vanara.PInvoke.NetApi32.NetUseGetInfo
[NetUserAdd](https://www.google.com/search?num=5&q=NetUserAdd+site%3Amicrosoft.com) | netapi32.dll | |
[NetUserChangePassword](https://www.google.com/search?num=5&q=NetUserChangePassword+site%3Amicrosoft.com) | netapi32.dll | |
[NetUserDel](https://www.google.com/search?num=5&q=NetUserDel+site%3Amicrosoft.com) | netapi32.dll | |
@ -167,31 +154,108 @@ Native Method | Native DLL | Header | Managed Method
[NetUserModalsSet](https://www.google.com/search?num=5&q=NetUserModalsSet+site%3Amicrosoft.com) | netapi32.dll | |
[NetUserSetGroups](https://www.google.com/search?num=5&q=NetUserSetGroups+site%3Amicrosoft.com) | netapi32.dll | |
[NetUserSetInfo](https://www.google.com/search?num=5&q=NetUserSetInfo+site%3Amicrosoft.com) | netapi32.dll | |
[NetValidateName](https://www.google.com/search?num=5&q=NetValidateName+site%3Amicrosoft.com) | netapi32.dll | |
[NetValidateName](http://msdn2.microsoft.com/en-us/library/772603df-ec17-4a83-a715-2d9a14d5c2bb) | netapi32.dll | lmjoin.h | Vanara.PInvoke.NetApi32.NetValidateName
[NetValidatePasswordPolicy](https://www.google.com/search?num=5&q=NetValidatePasswordPolicy+site%3Amicrosoft.com) | netapi32.dll | |
[NetValidatePasswordPolicyFree](https://www.google.com/search?num=5&q=NetValidatePasswordPolicyFree+site%3Amicrosoft.com) | netapi32.dll | |
[NetWkstaGetInfo](https://www.google.com/search?num=5&q=NetWkstaGetInfo+site%3Amicrosoft.com) | netapi32.dll | |
[NetWkstaSetInfo](https://www.google.com/search?num=5&q=NetWkstaSetInfo+site%3Amicrosoft.com) | netapi32.dll | |
[NetWkstaTransportAdd](https://www.google.com/search?num=5&q=NetWkstaTransportAdd+site%3Amicrosoft.com) | netapi32.dll | |
[NetWkstaTransportDel](https://www.google.com/search?num=5&q=NetWkstaTransportDel+site%3Amicrosoft.com) | netapi32.dll | |
[NetWkstaTransportEnum](https://www.google.com/search?num=5&q=NetWkstaTransportEnum+site%3Amicrosoft.com) | netapi32.dll | |
[NetWkstaUserEnum](https://www.google.com/search?num=5&q=NetWkstaUserEnum+site%3Amicrosoft.com) | netapi32.dll | |
[NetWkstaUserGetInfo](https://www.google.com/search?num=5&q=NetWkstaUserGetInfo+site%3Amicrosoft.com) | netapi32.dll | |
[NetWkstaUserSetInfo](https://www.google.com/search?num=5&q=NetWkstaUserSetInfo+site%3Amicrosoft.com) | netapi32.dll | |
[NetWkstaGetInfo](http://msdn2.microsoft.com/en-us/library/08777069-1afd-4482-8090-c65ef0bec1ea) | netapi32.dll | lmwksta.h | Vanara.PInvoke.NetApi32.NetWkstaGetInfo
[NetWkstaSetInfo](http://msdn2.microsoft.com/en-us/library/d746b6c9-5ef1-4174-a84f-44e4e50200cd) | netapi32.dll | lmwksta.h | Vanara.PInvoke.NetApi32.NetWkstaSetInfo
[NetWkstaTransportAdd](http://msdn2.microsoft.com/en-us/library/016060ea-eae1-421f-b708-5c2ddd2000c1) | netapi32.dll | lmwksta.h | Vanara.PInvoke.NetApi32.NetWkstaTransportAdd
[NetWkstaTransportDel](http://msdn2.microsoft.com/en-us/library/6d0ec459-8d7b-41fe-96dd-203e6a42164f) | netapi32.dll | lmwksta.h | Vanara.PInvoke.NetApi32.NetWkstaTransportDel
[NetWkstaTransportEnum](http://msdn2.microsoft.com/en-us/library/08bd22a9-00a7-4563-9353-c070ca9b2500) | netapi32.dll | lmwksta.h | Vanara.PInvoke.NetApi32.NetWkstaTransportEnum
[NetWkstaUserEnum](http://msdn2.microsoft.com/en-us/library/42eaeb70-3ce8-4eae-b20b-4729db90a7ef) | netapi32.dll | lmwksta.h | Vanara.PInvoke.NetApi32.NetWkstaUserEnum
[NetWkstaUserGetInfo](http://msdn2.microsoft.com/en-us/library/25ec7a49-fd26-4105-823b-a257a57f724e) | netapi32.dll | lmwksta.h | Vanara.PInvoke.NetApi32.NetWkstaUserGetInfo
[NetWkstaUserSetInfo](http://msdn2.microsoft.com/en-us/library/d48667a3-5ae9-4a7d-9af6-14f08835940d) | netapi32.dll | lmwksta.h | Vanara.PInvoke.NetApi32.NetWkstaUserSetInfo
### Structures
Native Structure | Header | Managed Structure
--- | --- | ---
[ADMIN_OTHER_INFO](http://msdn2.microsoft.com/en-us/library/43119dcf-7d04-4e3b-b1dc-20e814fbdc2f) | lmalert.h | Vanara.PInvoke.NetApi32+ADMIN_OTHER_INFO
[CONNECTION_INFO_0](http://msdn2.microsoft.com/en-us/library/aebafe24-1216-48ab-92db-df8f77d36f26) | lmshare.h | Vanara.PInvoke.NetApi32+CONNECTION_INFO_0
[CONNECTION_INFO_1](http://msdn2.microsoft.com/en-us/library/9904c448-dcc4-47cc-a2e0-7df8d4d37f3f) | lmshare.h | Vanara.PInvoke.NetApi32+CONNECTION_INFO_1
[DAV_CALLBACK_AUTH_BLOB](http://msdn2.microsoft.com/en-us/library/59976cb0-ed68-4db0-b8f8-cfe5e778916b) | davclnt.h | Vanara.PInvoke.NetApi32+DAV_CALLBACK_AUTH_BLOB
[DAV_CALLBACK_AUTH_UNP](http://msdn2.microsoft.com/en-us/library/47420a67-bf3f-40d9-bfc4-ac2cb2776a40) | davclnt.h | Vanara.PInvoke.NetApi32+DAV_CALLBACK_AUTH_UNP
[DAV_CALLBACK_CRED](http://msdn2.microsoft.com/en-us/library/5414d7b5-b506-4d0a-a4b8-89ab7878d674) | davclnt.h | Vanara.PInvoke.NetApi32+DAV_CALLBACK_CRED
[DOMAIN_CONTROLLER_INFO](http://msdn2.microsoft.com/en-us/library/ms675912) | DsGetDC.h | Vanara.PInvoke.NetApi32+DOMAIN_CONTROLLER_INFO
[DS_DOMAIN_TRUSTS](http://msdn2.microsoft.com/en-us/library/cd260fd1-dc38-4405-95ba-097a23faf668) | dsgetdc.h | Vanara.PInvoke.NetApi32+DS_DOMAIN_TRUSTS
[DSREG_USER_INFO](http://msdn2.microsoft.com/en-us/library/5E639988-0F53-40D7-BBEC-F78B3D124CC0) | lmjoin.h | Vanara.PInvoke.NetApi32+DSREG_USER_INFO
[DSROLE_OPERATION_STATE_INFO](http://msdn2.microsoft.com/en-us/library/c6c8e510-190a-47ad-805c-b8d3fbee836d) | dsrole.h | Vanara.PInvoke.NetApi32+DSROLE_OPERATION_STATE_INFO
[DSROLE_PRIMARY_DOMAIN_INFO_BASIC](http://msdn2.microsoft.com/en-us/library/8a7b34e8-46d6-46dc-9fef-ec37b0f65eea) | dsrole.h | Vanara.PInvoke.NetApi32+DSROLE_PRIMARY_DOMAIN_INFO_BASIC
[DSROLE_UPGRADE_STATUS_INFO](http://msdn2.microsoft.com/en-us/library/c368d8d9-a91d-4013-880e-36a47d42a697) | dsrole.h | Vanara.PInvoke.NetApi32+DSROLE_UPGRADE_STATUS_INFO
[SERVER_INFO_100](http://msdn2.microsoft.com/en-us/library/aa370897) | lm.h | Vanara.PInvoke.NetApi32+SERVER_INFO_100
[SERVER_INFO_101](http://msdn2.microsoft.com/en-us/library/aa370903) | lm.h | Vanara.PInvoke.NetApi32+SERVER_INFO_101
[SERVER_INFO_102](http://msdn2.microsoft.com/en-us/library/aa370904) | lm.h | Vanara.PInvoke.NetApi32+SERVER_INFO_102
[ERRLOG_OTHER_INFO](http://msdn2.microsoft.com/en-us/library/832ebe88-e1c4-4ce3-8057-922419b577f7) | lmalert.h | Vanara.PInvoke.NetApi32+ERRLOG_OTHER_INFO
[FILE_INFO_2](http://msdn2.microsoft.com/en-us/library/c80090d5-7064-4809-9185-02116f7ac2ef) | lmshare.h | Vanara.PInvoke.NetApi32+FILE_INFO_2
[FILE_INFO_3](http://msdn2.microsoft.com/en-us/library/67f5fa89-12c7-46fb-a118-de4bfed96923) | lmshare.h | Vanara.PInvoke.NetApi32+FILE_INFO_3
[NETSETUP_PROVISIONING_PARAMS](http://msdn2.microsoft.com/en-us/library/E965804F-145A-4D8F-BB8E-466580AC65DA) | lmjoin.h | Vanara.PInvoke.NetApi32+NETSETUP_PROVISIONING_PARAMS
[PRINT_OTHER_INFO](http://msdn2.microsoft.com/en-us/library/f2fd87bc-abde-43c0-b29d-d43cc5f038b8) | lmalert.h | Vanara.PInvoke.NetApi32+PRINT_OTHER_INFO
[SERVER_INFO_100](http://msdn2.microsoft.com/en-us/library/aa370897) | lmserver.h | Vanara.PInvoke.NetApi32+SERVER_INFO_100
[SERVER_INFO_101](http://msdn2.microsoft.com/en-us/library/aa370903) | lmserver.h | Vanara.PInvoke.NetApi32+SERVER_INFO_101
[SERVER_INFO_102](http://msdn2.microsoft.com/en-us/library/aa370904) | lmserver.h | Vanara.PInvoke.NetApi32+SERVER_INFO_102
[SERVER_INFO_402](http://msdn2.microsoft.com/en-us/library/51e5c27e-6a7d-45ac-9cfa-37b1f7f241f9) | lmserver.h | Vanara.PInvoke.NetApi32+SERVER_INFO_402
[SERVER_INFO_403](http://msdn2.microsoft.com/en-us/library/14309dbe-ad7b-4ae0-8acc-39e9999f411b) | lmserver.h | Vanara.PInvoke.NetApi32+SERVER_INFO_403
[SERVER_TRANSPORT_INFO_0](http://msdn2.microsoft.com/en-us/library/5b94cf7a-74d1-4ae8-87bd-22b2daf292cb) | lmserver.h | Vanara.PInvoke.NetApi32+SERVER_TRANSPORT_INFO_0
[SERVER_TRANSPORT_INFO_1](http://msdn2.microsoft.com/en-us/library/f21fed49-207a-4f64-becd-3d3c1e995eb0) | lmserver.h | Vanara.PInvoke.NetApi32+SERVER_TRANSPORT_INFO_1
[SERVER_TRANSPORT_INFO_2](http://msdn2.microsoft.com/en-us/library/b422eb71-1f93-432d-8283-81432edfe568) | lmserver.h | Vanara.PInvoke.NetApi32+SERVER_TRANSPORT_INFO_2
[SERVER_TRANSPORT_INFO_3](http://msdn2.microsoft.com/en-us/library/045d60d4-518f-4ce4-b611-e23d1588d5d3) | lmserver.h | Vanara.PInvoke.NetApi32+SERVER_TRANSPORT_INFO_3
[SESSION_INFO_0](http://msdn2.microsoft.com/en-us/library/6b39df47-f25c-41dd-ba15-6e6806c4ec89) | lmshare.h | Vanara.PInvoke.NetApi32+SESSION_INFO_0
[SESSION_INFO_1](http://msdn2.microsoft.com/en-us/library/bc1c985e-b8af-4134-9ae4-511d82e3909b) | lmshare.h | Vanara.PInvoke.NetApi32+SESSION_INFO_1
[SESSION_INFO_10](http://msdn2.microsoft.com/en-us/library/a23a5647-f99d-4cb8-9d84-93653a3e7428) | lmshare.h | Vanara.PInvoke.NetApi32+SESSION_INFO_10
[SESSION_INFO_2](http://msdn2.microsoft.com/en-us/library/c3429eba-4277-4dc7-9255-cd2ff18dc583) | lmshare.h | Vanara.PInvoke.NetApi32+SESSION_INFO_2
[SESSION_INFO_502](http://msdn2.microsoft.com/en-us/library/a86a00ae-f60a-4b12-a9ac-4b96f9abd6a2) | lmshare.h | Vanara.PInvoke.NetApi32+SESSION_INFO_502
[SHARE_INFO_0](http://msdn2.microsoft.com/en-us/library/47a74c71-1fcb-4c49-93b5-ea7cf3a0e567) | lmshare.h | Vanara.PInvoke.NetApi32+SHARE_INFO_0
[SHARE_INFO_1](http://msdn2.microsoft.com/en-us/library/9bc69340-4ea5-4180-ae5c-667c0a245b66) | lmshare.h | Vanara.PInvoke.NetApi32+SHARE_INFO_1
[SHARE_INFO_1004](http://msdn2.microsoft.com/en-us/library/41749066-d0e2-4a6b-aea5-216af9a530f4) | lmshare.h | Vanara.PInvoke.NetApi32+SHARE_INFO_1004
[SHARE_INFO_1005](http://msdn2.microsoft.com/en-us/library/9fb3e0ae-76b5-4432-80dd-f3361738aa7c) | lmshare.h | Vanara.PInvoke.NetApi32+SHARE_INFO_1005
[SHARE_INFO_1006](http://msdn2.microsoft.com/en-us/library/645a8670-5661-4d6c-8d9e-67c1bbb0f1d7) | lmshare.h | Vanara.PInvoke.NetApi32+SHARE_INFO_1006
[SHARE_INFO_1501](http://msdn2.microsoft.com/en-us/library/ef5d4936-8c0b-4a3c-b2b9-34868eb01a2e) | lmshare.h | Vanara.PInvoke.NetApi32+SHARE_INFO_1501
[SHARE_INFO_2](http://msdn2.microsoft.com/en-us/library/cd152ccd-cd60-455f-b25c-c4939c65e0ab) | lmshare.h | Vanara.PInvoke.NetApi32+SHARE_INFO_2
[SHARE_INFO_502](http://msdn2.microsoft.com/en-us/library/306e6704-2068-42da-bcc4-c0772c719ee8) | lmshare.h | Vanara.PInvoke.NetApi32+SHARE_INFO_502
[SHARE_INFO_503](http://msdn2.microsoft.com/en-us/library/12650bc0-f67d-464e-8386-a0fd53cdc749) | lmshare.h | Vanara.PInvoke.NetApi32+SHARE_INFO_503
[STD_ALERT](http://msdn2.microsoft.com/en-us/library/daa4594f-e59e-4f05-8183-677bee4ea446) | lmalert.h | Vanara.PInvoke.NetApi32+STD_ALERT
[TIME_OF_DAY_INFO](http://msdn2.microsoft.com/en-us/library/bf89f071-5c04-40c2-a7b7-4e59fc9eaa02) | lmremutl.h | Vanara.PInvoke.NetApi32+TIME_OF_DAY_INFO
[USE_INFO_0](http://msdn2.microsoft.com/en-us/library/86db3f19-84c5-4e89-82cb-f01d17dcf4ec) | lmuse.h | Vanara.PInvoke.NetApi32+USE_INFO_0
[USE_INFO_1](http://msdn2.microsoft.com/en-us/library/b9f680b8-b56a-42be-9af1-d7b18328ded4) | lmuse.h | Vanara.PInvoke.NetApi32+USE_INFO_1
[USE_INFO_2](http://msdn2.microsoft.com/en-us/library/4cc36108-085a-47c4-9dfa-b46f7e208c8b) | lmuse.h | Vanara.PInvoke.NetApi32+USE_INFO_2
[USE_INFO_3](http://msdn2.microsoft.com/en-us/library/3fb3ad35-f9e5-46ba-b930-fc2ccafd8ee9) | lmuse.h | Vanara.PInvoke.NetApi32+USE_INFO_3
[USE_INFO_4](https://www.google.com/search?num=5&q=USE_INFO_4+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+USE_INFO_4
[USE_INFO_5](https://www.google.com/search?num=5&q=USE_INFO_5+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+USE_INFO_5
[USER_OTHER_INFO](http://msdn2.microsoft.com/en-us/library/2f6bd906-fdab-410a-8856-4482e047371f) | lmalert.h | Vanara.PInvoke.NetApi32+USER_OTHER_INFO
[WKSTA_INFO_100](http://msdn2.microsoft.com/en-us/library/c705dadd-cf55-44d9-bf36-09e078112479) | lmwksta.h | Vanara.PInvoke.NetApi32+WKSTA_INFO_100
[WKSTA_INFO_101](http://msdn2.microsoft.com/en-us/library/2b692d40-6229-45ef-9ec6-ee464bba0696) | lmwksta.h | Vanara.PInvoke.NetApi32+WKSTA_INFO_101
[WKSTA_INFO_1010](https://www.google.com/search?num=5&q=WKSTA_INFO_1010+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1010
[WKSTA_INFO_1011](https://www.google.com/search?num=5&q=WKSTA_INFO_1011+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1011
[WKSTA_INFO_1012](https://www.google.com/search?num=5&q=WKSTA_INFO_1012+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1012
[WKSTA_INFO_1013](https://www.google.com/search?num=5&q=WKSTA_INFO_1013+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1013
[WKSTA_INFO_1018](https://www.google.com/search?num=5&q=WKSTA_INFO_1018+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1018
[WKSTA_INFO_102](http://msdn2.microsoft.com/en-us/library/01607fb5-c433-439c-aaaa-3736697f7c07) | lmwksta.h | Vanara.PInvoke.NetApi32+WKSTA_INFO_102
[WKSTA_INFO_1023](https://www.google.com/search?num=5&q=WKSTA_INFO_1023+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1023
[WKSTA_INFO_1027](https://www.google.com/search?num=5&q=WKSTA_INFO_1027+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1027
[WKSTA_INFO_1028](https://www.google.com/search?num=5&q=WKSTA_INFO_1028+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1028
[WKSTA_INFO_1032](https://www.google.com/search?num=5&q=WKSTA_INFO_1032+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1032
[WKSTA_INFO_1033](https://www.google.com/search?num=5&q=WKSTA_INFO_1033+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1033
[WKSTA_INFO_1041](https://www.google.com/search?num=5&q=WKSTA_INFO_1041+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1041
[WKSTA_INFO_1042](https://www.google.com/search?num=5&q=WKSTA_INFO_1042+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1042
[WKSTA_INFO_1043](https://www.google.com/search?num=5&q=WKSTA_INFO_1043+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1043
[WKSTA_INFO_1044](https://www.google.com/search?num=5&q=WKSTA_INFO_1044+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1044
[WKSTA_INFO_1045](https://www.google.com/search?num=5&q=WKSTA_INFO_1045+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1045
[WKSTA_INFO_1046](https://www.google.com/search?num=5&q=WKSTA_INFO_1046+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1046
[WKSTA_INFO_1047](https://www.google.com/search?num=5&q=WKSTA_INFO_1047+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1047
[WKSTA_INFO_1048](https://www.google.com/search?num=5&q=WKSTA_INFO_1048+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1048
[WKSTA_INFO_1049](https://www.google.com/search?num=5&q=WKSTA_INFO_1049+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1049
[WKSTA_INFO_1050](https://www.google.com/search?num=5&q=WKSTA_INFO_1050+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1050
[WKSTA_INFO_1051](https://www.google.com/search?num=5&q=WKSTA_INFO_1051+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1051
[WKSTA_INFO_1052](https://www.google.com/search?num=5&q=WKSTA_INFO_1052+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1052
[WKSTA_INFO_1053](https://www.google.com/search?num=5&q=WKSTA_INFO_1053+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1053
[WKSTA_INFO_1054](https://www.google.com/search?num=5&q=WKSTA_INFO_1054+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1054
[WKSTA_INFO_1055](https://www.google.com/search?num=5&q=WKSTA_INFO_1055+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1055
[WKSTA_INFO_1056](https://www.google.com/search?num=5&q=WKSTA_INFO_1056+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1056
[WKSTA_INFO_1057](https://www.google.com/search?num=5&q=WKSTA_INFO_1057+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1057
[WKSTA_INFO_1058](https://www.google.com/search?num=5&q=WKSTA_INFO_1058+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1058
[WKSTA_INFO_1059](https://www.google.com/search?num=5&q=WKSTA_INFO_1059+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1059
[WKSTA_INFO_1060](https://www.google.com/search?num=5&q=WKSTA_INFO_1060+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1060
[WKSTA_INFO_1061](https://www.google.com/search?num=5&q=WKSTA_INFO_1061+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1061
[WKSTA_INFO_1062](https://www.google.com/search?num=5&q=WKSTA_INFO_1062+site%3Amicrosoft.com) | | Vanara.PInvoke.NetApi32+WKSTA_INFO_1062
[WKSTA_INFO_302](https://www.google.com/search?num=5&q=WKSTA_INFO_302+site%3Amicrosoft.com) | lmwksta.h | Vanara.PInvoke.NetApi32+WKSTA_INFO_302
[WKSTA_INFO_402](https://www.google.com/search?num=5&q=WKSTA_INFO_402+site%3Amicrosoft.com) | lmwksta.h | Vanara.PInvoke.NetApi32+WKSTA_INFO_402
[WKSTA_INFO_502](http://msdn2.microsoft.com/en-us/library/716e700a-e464-47ec-a2df-74c03597ac6d) | lmwksta.h | Vanara.PInvoke.NetApi32+WKSTA_INFO_502
[WKSTA_TRANSPORT_INFO_0](http://msdn2.microsoft.com/en-us/library/e7afe2a3-f729-4fd5-afc3-d3ffbd09e884) | lmwksta.h | Vanara.PInvoke.NetApi32+WKSTA_TRANSPORT_INFO_0
[WKSTA_USER_INFO_0](http://msdn2.microsoft.com/en-us/library/8bd8d8c7-4558-46cb-ab46-a2197d53e9f7) | lmwksta.h | Vanara.PInvoke.NetApi32+WKSTA_USER_INFO_0
[WKSTA_USER_INFO_1](http://msdn2.microsoft.com/en-us/library/a30747de-6cb0-41dc-95a7-be3d471056d5) | lmwksta.h | Vanara.PInvoke.NetApi32+WKSTA_USER_INFO_1
[WKSTA_USER_INFO_1101](http://msdn2.microsoft.com/en-us/library/88772ba2-046b-4b03-ae02-d851075e4363) | lmwksta.h | Vanara.PInvoke.NetApi32+WKSTA_USER_INFO_1101

View File

@ -136,6 +136,7 @@ namespace Vanara.PInvoke
/// <summary>Authentication scheme.</summary>
[PInvokeData("davclnt.h", MSDNShortId = "6ac191ac-e63f-431f-893b-92c69320db58")]
[Flags]
public enum DAV_AUTHN_SCHEME
{
/// <summary>Basic authentication is to be used.</summary>

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using System.Linq;
using Vanara.InteropServices;
using static Vanara.PInvoke.AdvApi32;
using static Vanara.PInvoke.Ws2_32;
@ -316,34 +317,24 @@ namespace Vanara.PInvoke
DS_GFTI_UPDATE_TDO = 1
}
/// <summary>
/// <para>The <c>DsAddressToSiteNames</c> function obtains the site names corresponding to the specified addresses.</para>
/// </summary>
/// <summary>The <c>DsAddressToSiteNames</c> function obtains the site names corresponding to the specified addresses.</summary>
/// <param name="ComputerName">
/// <para>
/// Pointer to a null-terminated string that specifies the name of the remote server to process this function. This parameter must be
/// the name of a domain controller. A non-domain controller can call this function by calling DsGetDcName to find the domain controller.
/// </para>
/// </param>
/// <param name="EntryCount">
/// <para>Contains the number of elements in the SocketAddresses array.</para>
/// </param>
/// <param name="EntryCount">Contains the number of elements in the SocketAddresses array.</param>
/// <param name="SocketAddresses">
/// <para>
/// Contains an array of SOCKET_ADDRESS structures that contain the addresses to convert. Each address in this array must be of the
/// type <c>AF_INET</c>. EntryCount contains the number of elements in this array.
/// </para>
/// </param>
/// <param name="SiteNames">
/// <para>
/// Receives an array of null-terminated string pointers that contain the site names for the addresses. Each element in this array
/// corresponds to the same element in the SocketAddresses array. An element is <c>NULL</c> if the corresponding address does not map
/// to any known site or if the address entry is not of the proper form. The caller must free this array when it is no longer
/// required by calling NetApiBufferFree.
/// </para>
/// </param>
/// <returns>
/// <para>Returns <c>NO_ERROR</c> if successful or a Win32 or RPC error otherwise. The following list lists possible error codes.</para>
/// Returns <c>NO_ERROR</c> if successful or a Win32 or RPC error otherwise. The following list lists possible error codes.
/// </returns>
// https://docs.microsoft.com/en-us/windows/desktop/api/dsgetdc/nf-dsgetdc-dsaddresstositenamesa DSGETDCAPI DWORD
// DsAddressToSiteNamesA( IN LPCSTR ComputerName, IN DWORD EntryCount, IN PSOCKET_ADDRESS SocketAddresses, OUT LPSTR **SiteNames );
@ -351,47 +342,32 @@ namespace Vanara.PInvoke
[PInvokeData("dsgetdc.h", MSDNShortId = "4d70dbee-be33-4d2a-a200-3696443fa853")]
public static extern Win32Error DsAddressToSiteNames(string ComputerName, uint EntryCount, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] SOCKET_ADDRESS[] SocketAddresses, out SafeNetApiBuffer SiteNames);
/// <summary>
/// <para>The <c>DsAddressToSiteNamesEx</c> function obtains the site and subnet names corresponding to the addresses specified.</para>
/// </summary>
/// <summary>The <c>DsAddressToSiteNamesEx</c> function obtains the site and subnet names corresponding to the addresses specified.</summary>
/// <param name="ComputerName">
/// <para>
/// Pointer to a null-terminated string that specifies the name of the remote server to process this function. This parameter must be
/// the name of a domain controller. A non-domain controller can call this function by calling DsGetDcName to find the domain controller.
/// </para>
/// </param>
/// <param name="EntryCount">
/// <para>Contains the number of elements in the SocketAddresses array.</para>
/// </param>
/// <param name="EntryCount">Contains the number of elements in the SocketAddresses array.</param>
/// <param name="SocketAddresses">
/// <para>
/// Contains an array of SOCKET_ADDRESS structures that contain the addresses to convert. Each address in this array must be of the
/// type <c>AF_INET</c>. EntryCount contains the number of elements in this array.
/// </para>
/// </param>
/// <param name="SiteNames">
/// <para>
/// Receives an array of null-terminated string pointers that contain the site names for the addresses. Each element in this array
/// corresponds to the same element in the SocketAddresses array. An element is <c>NULL</c> if the corresponding address does not map
/// to any known site or if the address entry is not of the proper form. The caller must free this array when it is no longer
/// required by calling NetApiBufferFree.
/// </para>
/// </param>
/// <param name="SubnetNames">
/// <para>
/// Receives an array of null-terminated string pointers that contain the subnet names used to perform the address to site name
/// mappings. Each element in this array corresponds to the same element in the SocketAddresses array. An element is <c>NULL</c> if
/// the corresponding address to site name mapping was not determined or if no subnet was used to perform the corresponding address
/// to site mapping. The latter will be the case when there is exactly one site in the enterprise with no subnet objects mapped to
/// it. The caller must free this array when it is no longer required by calling NetApiBufferFree.
/// </para>
/// </param>
/// <returns>
/// <para>Returns <c>NO_ERROR</c> if successful or a Win32 or RPC error otherwise. The following are possible error codes.</para>
/// </returns>
// https://docs.microsoft.com/en-us/windows/desktop/api/dsgetdc/nf-dsgetdc-dsaddresstositenamesexa DSGETDCAPI DWORD
// DsAddressToSiteNamesExA( IN LPCSTR ComputerName, IN DWORD EntryCount, IN PSOCKET_ADDRESS SocketAddresses, OUT LPSTR **SiteNames,
// OUT LPSTR **SubnetNames );
/// <returns>Returns <c>NO_ERROR</c> if successful or a Win32 or RPC error otherwise. The following are possible error codes.</returns>
// https://docs.microsoft.com/en-us/windows/desktop/api/dsgetdc/nf-dsgetdc-dsaddresstositenamesexw
// DSGETDCAPI DWORD DsAddressToSiteNamesExW( IN LPCWSTR ComputerName, IN DWORD EntryCount, IN PSOCKET_ADDRESS SocketAddresses, OUT LPWSTR **SiteNames, OUT LPWSTR **SubnetNames );
[DllImport(Lib.NetApi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("dsgetdc.h", MSDNShortId = "60ac6195-6e43-46da-a1e6-74ec989cd0c4")]
public static extern Win32Error DsAddressToSiteNamesEx(string ComputerName, uint EntryCount, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] SOCKET_ADDRESS[] SocketAddresses, out SafeNetApiBuffer SiteNames, out SafeNetApiBuffer SubnetNames);
@ -492,11 +468,8 @@ namespace Vanara.PInvoke
[PInvokeData("dsgetdc.h", MSDNShortId = "18ab6455-dab2-42d9-b68e-a8f0ad2d8091")]
public static extern Win32Error DsDeregisterDnsHostRecords([Optional] string ServerName, string DnsDomainName, IntPtr DomainGuid, IntPtr DsaGuid, string DnsHostName);
/// <summary>
/// <para>The <c>DsEnumerateDomainTrusts</c> function obtains domain trust data for a specified domain.</para>
/// </summary>
/// <param name="ServerName">
/// <para>
/// <summary>The <c>DsEnumerateDomainTrusts</c> function obtains domain trust data for a specified domain.</summary>
/// <param name="ServerName"><para>
/// Pointer to a null-terminated string that specifies the name of a computer in the domain to obtain the trust information for. If
/// this parameter is <c>NULL</c>, the name of the local computer is used. The caller must be an authenticated user in this domain.
/// </para>
@ -505,10 +478,8 @@ namespace Vanara.PInvoke
/// controller, this function obtains the trust data from cached data if the cached data is not expired. If the cached data is
/// expired, this function obtains the trust data from a domain controller in the domain that this computer is a member of and
/// updates the cache. The cached data automatically expires after five minutes.
/// </para>
/// </param>
/// <param name="Flags">
/// <para>
/// </para></param>
/// <param name="Flags"><para>
/// Contains a set of flags that determines which domain trusts to enumerate. This can be zero or a combination of one or more of the
/// following values.
/// </para>
@ -523,28 +494,19 @@ namespace Vanara.PInvoke
/// <para>DS_DOMAIN_PRIMARY</para>
/// <para>Enumerate domains that are the primary domain of the domain which has ServerName as a member.</para>
/// <para>DS_DOMAIN_TREE_ROOT</para>
/// <para>Enumerate domains that are at the root of the forest which has ServerName as a member.</para>
/// </param>
/// <param name="Domains">
/// <para>
/// Pointer to a <c>PDS_DOMAIN_TRUSTS</c> value that receives an array of DS_DOMAIN_TRUSTS structures. Each structure in this array
/// contains trust data about a domain. The caller must free this memory when it is no longer required by calling NetApiBufferFree.
/// </para>
/// </param>
/// <param name="DomainCount">
/// <para>Pointer to a <c>ULONG</c> value that receives the number of elements returned in the Domains array.</para>
/// </param>
/// <para>Enumerate domains that are at the root of the forest which has ServerName as a member.</para></param>
/// <param name="Domains">Pointer to a <c>PDS_DOMAIN_TRUSTS</c> value that receives an array of DS_DOMAIN_TRUSTS structures. Each structure in this array
/// contains trust data about a domain. The caller must free this memory when it is no longer required by calling NetApiBufferFree.</param>
/// <param name="DomainCount">Pointer to a <c>ULONG</c> value that receives the number of elements returned in the Domains array.</param>
/// <returns>
/// <para>
/// Returns <c>ERROR_SUCCESS</c> if successful or a Win32 error code otherwise. Possible error codes include those listed in the
/// following list.
/// </para>
/// </returns>
// https://docs.microsoft.com/en-us/windows/desktop/api/dsgetdc/nf-dsgetdc-dsenumeratedomaintrustsa DSGETDCAPI DWORD
// DsEnumerateDomainTrustsA( LPSTR ServerName, ULONG Flags, PDS_DOMAIN_TRUSTSA *Domains, PULONG DomainCount );
[DllImport(Lib.NetApi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("dsgetdc.h", MSDNShortId = "6c3b788f-ee53-4637-acdb-04316e8464fe")]
public static extern Win32Error DsEnumerateDomainTrusts([Optional] string ServerName, DomainTrustFlag Flags, out SafeNetApiBuffer Domains, out uint DomainCount);
public static extern Win32Error DsEnumerateDomainTrusts([Optional] string ServerName, [Optional] DomainTrustFlag Flags, out SafeNetApiBuffer Domains, out uint DomainCount);
/// <summary>
/// <para>The <c>DsGetDcClose</c> function closes a domain controller enumeration operation.</para>
@ -562,7 +524,351 @@ namespace Vanara.PInvoke
// GetDcContextHandle );
[DllImport(Lib.NetApi32, SetLastError = false, EntryPoint = "DsGetDcCloseW")]
[PInvokeData("dsgetdc.h", MSDNShortId = "d193e4cd-ad66-4d93-b912-348f17e93a6f")]
public static extern void DsGetDcClose(SafeDCEnumHandle GetDcContextHandle);
public static extern void DsGetDcClose(HANDLE GetDcContextHandle);
/// <summary>
/// The <c>DsGetDcName</c> function returns the name of a domain controller in a specified domain. This function accepts additional
/// domain controller selection criteria to indicate preference for a domain controller with particular characteristics.
/// </summary>
/// <param name="ComputerName">
/// Pointer to a null-terminated string that specifies the name of the server to process this function. Typically, this parameter is
/// <c>NULL</c>, which indicates that the local computer is used.
/// </param>
/// <param name="DomainName">
/// <para>
/// Pointer to a null-terminated string that specifies the name of the domain or application partition to query. This name can either
/// be a DNS style name, for example, fabrikam.com, or a flat-style name, for example, Fabrikam. If a DNS style name is specified,
/// the name may be specified with or without a trailing period.
/// </para>
/// <para>
/// If the Flags parameter contains the <c>DS_GC_SERVER_REQUIRED</c> flag, DomainName must be the name of the forest. In this case,
/// <c>DsGetDcName</c> fails if DomainName specifies a name that is not the forest root.
/// </para>
/// <para>
/// If the Flags parameter contains the <c>DS_GC_SERVER_REQUIRED</c> flag and DomainName is <c>NULL</c>, <c>DsGetDcName</c> attempts
/// to find a global catalog in the forest of the computer identified by ComputerName, which is the local computer if ComputerName is <c>NULL</c>.
/// </para>
/// <para>
/// If DomainName is <c>NULL</c> and the Flags parameter does not contain the <c>DS_GC_SERVER_REQUIRED</c> flag, ComputerName is set
/// to the default domain name of the primary domain of the computer identified by ComputerName.
/// </para>
/// </param>
/// <param name="DomainGuid">
/// Pointer to a GUID structure that specifies the <c>GUID</c> of the domain queried. If DomainGuid is not <c>NULL</c> and the domain
/// specified by DomainName or ComputerName cannot be found, <c>DsGetDcName</c> attempts to locate a domain controller in the domain
/// having the GUID specified by DomainGuid.
/// </param>
/// <param name="SiteName">
/// Pointer to a null-terminated string that specifies the name of the site where the returned domain controller should physically
/// exist. If this parameter is <c>NULL</c>, <c>DsGetDcName</c> attempts to return a domain controller in the site closest to the
/// site of the computer specified by ComputerName. This parameter should be <c>NULL</c>, by default.
/// </param>
/// <param name="Flags">
/// <para>
/// Contains a set of flags that provide additional data used to process the request. This parameter can be a combination of the
/// following values.
/// </para>
/// <para>DS_AVOID_SELF</para>
/// <para>
/// When called from a domain controller, specifies that the returned domain controller name should not be the current computer. If
/// the current computer is not a domain controller, this flag is ignored. This flag can be used to obtain the name of another domain
/// controller in the domain.
/// </para>
/// <para>DS_BACKGROUND_ONLY</para>
/// <para>
/// If the <c>DS_FORCE_REDISCOVERY</c> flag is not specified, this function uses cached domain controller data. If the cached data is
/// more than 15 minutes old, the cache is refreshed by pinging the domain controller. If this flag is specified, this refresh is
/// avoided even if the cached data is expired. This flag should be used if the <c>DsGetDcName</c> function is called periodically.
/// </para>
/// <para>DS_DIRECTORY_SERVICE_PREFERRED</para>
/// <para>
/// <c>DsGetDcName</c> attempts to find a domain controller that supports directory service functions. If a domain controller that
/// supports directory services is not available, <c>DsGetDcName</c> returns the name of a non-directory service domain controller.
/// However, <c>DsGetDcName</c> only returns a non-directory service domain controller after the attempt to find a directory service
/// domain controller times out.
/// </para>
/// <para>DS_DIRECTORY_SERVICE_REQUIRED</para>
/// <para>Requires that the returned domain controller support directory services.</para>
/// <para>DS_DIRECTORY_SERVICE_6_REQUIRED</para>
/// <para>Requires that the returned domain controller be running Windows Server 2008 or later.</para>
/// <para>DS_DIRECTORY_SERVICE_8_REQUIRED</para>
/// <para>Requires that the returned domain controller be running Windows Server 2012 or later.</para>
/// <para>DS_FORCE_REDISCOVERY</para>
/// <para>
/// Forces cached domain controller data to be ignored. When the <c>DS_FORCE_REDISCOVERY</c> flag is not specified,
/// <c>DsGetDcName</c> may return cached domain controller data. If this flag is specified, <c>DsGetDcName</c> will not use cached
/// information (if any exists) but will instead perform a fresh domain controller discovery.
/// </para>
/// <para>
/// This flag should not be used under normal conditions, as using the cached domain controller information has better performance
/// characteristics and helps to ensure that the same domain controller is used consistently by all applications. This flag should be
/// used only after the application determines that the domain controller returned by <c>DsGetDcName</c> (when called without this
/// flag) is not accessible. In that case, the application should repeat the <c>DsGetDcName</c> call with this flag to ensure that
/// the unuseful cached information (if any) is ignored and a reachable domain controller is discovered.
/// </para>
/// <para>DS_GC_SERVER_REQUIRED</para>
/// <para>
/// Requires that the returned domain controller be a global catalog server for the forest of domains with this domain as the root.
/// If this flag is set and the DomainName parameter is not <c>NULL</c>, DomainName must specify a forest name. This flag cannot be
/// combined with the <c>DS_PDC_REQUIRED</c> or <c>DS_KDC_REQUIRED</c> flags.
/// </para>
/// <para>DS_GOOD_TIMESERV_PREFERRED</para>
/// <para>
/// <c>DsGetDcName</c> attempts to find a domain controller that is a reliable time server. The Windows Time Service can be
/// configured to declare one or more domain controllers as a reliable time server. For more information, see the Windows Time
/// Service documentation. This flag is intended to be used only by the Windows Time Service.
/// </para>
/// <para>DS_IP_REQUIRED</para>
/// <para>
/// This parameter indicates that the domain controller must have an IP address. In that case, <c>DsGetDcName</c> will place the
/// Internet protocol address of the domain controller in the <c>DomainControllerAddress</c> member of DomainControllerInfo.
/// </para>
/// <para>DS_IS_DNS_NAME</para>
/// <para>Specifies that the DomainName parameter is a DNS name. This flag cannot be combined with the <c>DS_IS_FLAT_NAME</c> flag.</para>
/// <para>
/// Specify either <c>DS_IS_DNS_NAME</c> or <c>DS_IS_FLAT_NAME</c>. If neither flag is specified, <c>DsGetDcName</c> may take longer
/// to find a domain controller because it may have to search for both the DNS-style and flat name.
/// </para>
/// <para>DS_IS_FLAT_NAME</para>
/// <para>Specifies that the DomainName parameter is a flat name. This flag cannot be combined with the <c>DS_IS_DNS_NAME</c> flag.</para>
/// <para>DS_KDC_REQUIRED</para>
/// <para>
/// Requires that the returned domain controller be currently running the Kerberos Key Distribution Center service. This flag cannot
/// be combined with the <c>DS_PDC_REQUIRED</c> or <c>DS_GC_SERVER_REQUIRED</c> flags.
/// </para>
/// <para>DS_ONLY_LDAP_NEEDED</para>
/// <para>
/// Specifies that the server returned is an LDAP server. The server returned is not necessarily a domain controller. No other
/// services are implied to be present at the server. The server returned does not necessarily have a writable <c>config</c>
/// container nor a writable <c>schema</c> container. The server returned may not necessarily be used to create or modify security
/// principles. This flag may be used with the <c>DS_GC_SERVER_REQUIRED</c> flag to return an LDAP server that also hosts a global
/// catalog server. The returned global catalog server is not necessarily a domain controller. No other services are implied to be
/// present at the server. If this flag is specified, the <c>DS_PDC_REQUIRED</c>, <c>DS_TIMESERV_REQUIRED</c>,
/// <c>DS_GOOD_TIMESERV_PREFERRED</c>, <c>DS_DIRECTORY_SERVICES_PREFERED</c>, <c>DS_DIRECTORY_SERVICES_REQUIRED</c>, and
/// <c>DS_KDC_REQUIRED</c> flags are ignored.
/// </para>
/// <para>DS_PDC_REQUIRED</para>
/// <para>
/// Requires that the returned domain controller be the primary domain controller for the domain. This flag cannot be combined with
/// the <c>DS_KDC_REQUIRED</c> or <c>DS_GC_SERVER_REQUIRED</c> flags.
/// </para>
/// <para>DS_RETURN_DNS_NAME</para>
/// <para>
/// Specifies that the names returned in the <c>DomainControllerName</c> and <c>DomainName</c> members of DomainControllerInfo should
/// be DNS names. If a DNS name is not available, an error is returned. This flag cannot be specified with the
/// <c>DS_RETURN_FLAT_NAME</c> flag. This flag implies the <c>DS_IP_REQUIRED</c> flag.
/// </para>
/// <para>DS_RETURN_FLAT_NAME</para>
/// <para>
/// Specifies that the names returned in the <c>DomainControllerName</c> and <c>DomainName</c> members of DomainControllerInfo should
/// be flat names. If a flat name is not available, an error is returned. This flag cannot be specified with the
/// <c>DS_RETURN_DNS_NAME</c> flag.
/// </para>
/// <para>DS_TIMESERV_REQUIRED</para>
/// <para>Requires that the returned domain controller be currently running the Windows Time Service.</para>
/// <para>DS_TRY_NEXTCLOSEST_SITE</para>
/// <para>
/// When this flag is specified, <c>DsGetDcName</c> attempts to find a domain controller in the same site as the caller. If no such
/// domain controller is found, it will find a domain controller that can provide topology information and call DsBindToISTG to
/// obtain a bind handle, then call DsQuerySitesByCost over UDP to determine the "next closest site," and finally cache the name of
/// the site found. If no domain controller is found in that site, then <c>DsGetDcName</c> falls back on the default method of
/// locating a domain controller.
/// </para>
/// <para>
/// If this flag is used in conjunction with a non-NULL value in the input parameter SiteName, then <c>ERROR_INVALID_FLAGS</c> is thrown.
/// </para>
/// <para>
/// Also, the kind of search employed with <c>DS_TRY_NEXT_CLOSEST_SITE</c> is site-specific, so this flag is ignored if it is used in
/// conjunction with <c>DS_PDC_REQUIRED</c>. Finally, <c>DS_TRY_NEXTCLOSEST_SITE</c> is ignored when used in conjunction with
/// <c>DS_RETURN_FLAT_NAME</c> because that uses NetBIOS to resolve the name, but the domain of the domain controller found won't
/// necessarily match the domain to which the client is joined.
/// </para>
/// <para>
/// <c>Note</c> This flag is Group Policy enabled. If you enable the "Next Closest Site" policy setting, Next Closest Site DC
/// Location will be turned on for the machine across all available but un-configured network adapters. If you disable the policy
/// setting, Next Closest Site DC Location will not be used by default for the machine across all available but un-configured network
/// adapters. However, if a DC Locator call is made using the <c>DS_TRY_NEXTCLOSEST_SITE</c> flag explicitly, <c>DsGetDcName</c>
/// honors the Next Closest Site behavior. If you do not configure this policy setting, Next Closest Site DC Location will be not be
/// used by default for the machine across all available but un-configured network adapters. If the <c>DS_TRY_NEXTCLOSEST_SITE</c>
/// flag is used explicitly, the Next Closest Site behavior will be used.
/// </para>
/// <para>DS_WRITABLE_REQUIRED</para>
/// <para>Requires that the returned domain controller be writable; that is, host a writable copy of the directory service.</para>
/// <para>DS_WEB_SERVICE_REQUIRED</para>
/// <para>Requires that the returned domain controller be currently running the Active Directory web service.</para>
/// </param>
/// <param name="DomainControllerInfo">
/// Pointer to a <c>PDOMAIN_CONTROLLER_INFO</c> value that receives a pointer to a DOMAIN_CONTROLLER_INFO structure that contains
/// data about the domain controller selected. This structure is allocated by <c>DsGetDcName</c>. The caller must free the structure
/// using the NetApiBufferFree function when it is no longer required.
/// </param>
/// <returns>
/// <para>If the function returns domain controller data, the return value is <c>ERROR_SUCCESS</c>.</para>
/// <para>If the function fails, the return value can be one of the following error codes.</para>
/// </returns>
/// <remarks>
/// <para>
/// The <c>DsGetDcName</c> function is sent to the Netlogon service on the remote computer specified by ComputerName. If ComputerName
/// is <c>NULL</c>, the function is processed on the local computer.
/// </para>
/// <para>
/// <c>DsGetDcName</c> does not verify that the domain controller name returned is the name of an actual domain controller or global
/// catalog. If mutual authentication is required, the caller must perform the authentication.
/// </para>
/// <para>
/// <c>DsGetDcName</c> does not require any particular access to the specified domain. By default, this function does not ensure that
/// the returned domain controller is currently available. Instead, the caller should attempt to use the returned domain controller.
/// If the domain controller is not available, the caller should call the <c>DsGetDcName</c> function again, specifying the
/// <c>DS_FORCE_REDISCOVERY</c> flag.
/// </para>
/// <para>Response Time</para>
/// <para>When using <c>DsGetDcName</c> be aware of the following timing details:</para>
/// <list type="bullet">
/// <item>
/// <term>
/// <c>DsGetDcName</c> makes network calls and can take from a few seconds up to one minute, depending on network traffic, topology,
/// DC load, and so on.
/// </term>
/// </item>
/// <item>
/// <term>It is NOT recommended to call <c>DsGetDcName</c> from a UI or other timing critical thread.</term>
/// </item>
/// <item>
/// <term>
/// The DC Locator does use optimized logic to provide the DC information as quickly as possible. It also uses cached information at
/// the site to contact the closest DC.
/// </term>
/// </item>
/// </list>
/// <para>Notes on Domain Controller Stickiness</para>
/// <para>
/// In Active Directory Domain Services, the domain controller locator function is designed so that once a client finds a preferred
/// domain controller, the client will not look for another unless that domain controller stops responding or the client is
/// restarted. This is referred to as "Domain Controller Stickiness." Because workstations typically operate for months without a
/// problem or restart, one unintended consequence of this behavior is that if a particular domain controller goes down for
/// maintenance, all of the clients that were connected to it shift their connections to another domain controller. But when the
/// domain controller comes back up, no clients ever reconnect to it because the clients do not restart very often. This can cause
/// load-balancing problems.
/// </para>
/// <para>
/// Previously, the most common solution to this problem was to deploy a script on each client machine that periodically called
/// <c>DsGetDcName</c> using the flag. This was a somewhat cumbersome solution, so Windows Server 2008 and Windows Vista introduced a
/// new mechanism that caused issues with domain controller stickiness.
/// </para>
/// <para>
/// Whenever <c>DsGetDcName</c> retrieves a domain controller name from its cache, it checks to see if this cached entry is expired,
/// and if so, discards that domain controller name and tries to rediscover a domain controller name. The life span of a cached entry
/// is controlled by the value in the following registry keys
/// </para>
/// <para><c>HKEY_LOCAL_MACHINE</c>&lt;b&gt;SYSTEM&lt;b&gt;CurrentControlSet&lt;b&gt;Services&lt;b&gt;Netlogon&lt;b&gt;Parameters&lt;b&gt;ForceRediscoveryInterval</para>
/// <para>and</para>
/// <para><c>HKEY_LOCAL_MACHINE</c>&lt;b&gt;Software&lt;b&gt;Policies&lt;b&gt;Microsoft&lt;b&gt;Netlogon&lt;b&gt;Parameters&lt;b&gt;ForceRediscoveryInterval</para>
/// <para>
/// The values in these registry keys are of type <c>REG_DWORD</c>. They specify the length in seconds before <c>DsGetDcName</c>
/// should try to rediscover the domain controller name. The default value is 43200 seconds (12 hours). If the value of the
/// <c>ForceRediscoveryInterval</c> registry entry is set to 0, the client always performs rediscovery. If the value is set to
/// 4294967295, the cache never expires, and the cached domain controller continues to be used. We recommend that you do not set the
/// <c>ForceRediscoveryInterval</c> registry entry to a value that is less than 3600 seconds (60 minutes).
/// </para>
/// <para>
/// <c>Note</c> The registry settings of <c>ForceRediscoveryInterval</c> are group policy enabled. If you disable the policy setting,
/// Force Rediscovery will used by default for the machine at every 12 hour interval. If you do not configure this policy setting,
/// Force Rediscovery will used by default for the machine at every 12 hour interval, unless the local machine setting in the
/// registry is a different value.
/// </para>
/// <para>
/// Note that if the <c>DS_BACKGROUND_ONLY</c> flag is specified, <c>DsGetDcName</c> will never try to rediscover the domain
/// controller name, since the point of that flag is to force <c>DsGetDcName</c> to use the cached domain controller name even if it
/// is expired.
/// </para>
/// <para>ETW Tracing in DsGetDcName</para>
/// <para>To turn on ETW Tracing for <c>DsGetDcName</c>, create the following registry key:</para>
/// <para><c>HKEY_LOCAL_MACHINE</c>&lt;b&gt;System&lt;b&gt;CurrentControlSet&lt;b&gt;Services&lt;b&gt;DCLocator&lt;b&gt;Tracing</para>
/// <para>The key will have a structure as follows:</para>
/// <para>
/// ProcessName must be the full name including extension of the process that you want to get trace information for. PID is only
/// required when multiple processes with the same name exist. If it is defined, then only the process with that PID will be enabled
/// for tracing. It is not possible to trace only 2 out of 3 (or more) processes with the same name. You can enable one instance or
/// all instances (when multiple instances with the same process name exist and PID is not specified, all instances will be enabled
/// for tracing).
/// </para>
/// <para>
/// For example, this would trace all instances of App1.exe and App2.exe, but only the instance of App3.exe that has a PID of 999:
/// </para>
/// <para>Run the following command to start the tracing session:</para>
/// <para><c>tracelog.exe -start &lt;sessionname&gt; -guid #cfaa5446-c6c4-4f5c-866f-31c9b55b962d -f &lt;filename&gt; -flag &lt;traceFlags&gt;</c></para>
/// <para>
/// sessionname is the name given for the trace session. The guid for the DCLocator tracing provider is
/// "cfaa5446-c6c4-4f5c-866f-31c9b55b962d". filename is the name of the log file to which the events are written. traceFlags is one
/// or more of the following flags which signify which areas to trace:
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Flag</term>
/// <term>Hex Value</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>DCLOCATOR_MISC</term>
/// <term>0x00000002</term>
/// <term>Miscellaneous debugging</term>
/// </item>
/// <item>
/// <term>DCLOCATOR_MAILSLOT</term>
/// <term>0x00000010</term>
/// <term>Mailslot messages</term>
/// </item>
/// <item>
/// <term>DCLOCATOR_SITE</term>
/// <term>0x00000020</term>
/// <term>Sites</term>
/// </item>
/// <item>
/// <term>DCLOCATOR_CRITICAL</term>
/// <term>0x00000100</term>
/// <term>Important errors</term>
/// </item>
/// <item>
/// <term>DCLOCATOR_SESSION_SETUP</term>
/// <term>0x00000200</term>
/// <term>Trusted Domain Maintenance</term>
/// </item>
/// <item>
/// <term>DCLOCATOR_DNS</term>
/// <term>0x00004000</term>
/// <term>Name Registration</term>
/// </item>
/// <item>
/// <term>DCLOCATOR_DNS_MORE</term>
/// <term>0x00020000</term>
/// <term>Verbose Name Registration</term>
/// </item>
/// <item>
/// <term>DCLOCATOR_MAILBOX_TEXT</term>
/// <term>0x02000000</term>
/// <term>Verbose Mailbox Messages</term>
/// </item>
/// <item>
/// <term>DCLOCATOR_SITE_MORE</term>
/// <term>0x08000000</term>
/// <term>Verbose sites</term>
/// </item>
/// </list>
/// <para>Run the following command to stop the trace session:</para>
/// <para><c>tracelog.exe -stop &lt;sessionname&gt;</c></para>
/// <para>sessionname is the same name as the name you used when starting the session.</para>
/// <para>
/// <c>Note</c> The registry key for the process being traced must be present in the registry at the time the trace session is
/// started. When the session starts, the process will verify whether or not it should be generating trace messages (based on the
/// presence or absence of a registry key for that process name and optional PID). The process checks the registry only at the start
/// of the session. Any changes in the registry occurring after that will not have any effect on tracing.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/dsgetdc/nf-dsgetdc-dsgetdcnamea
// DSGETDCAPI DWORD DsGetDcNameA( IN LPCSTR ComputerName, IN LPCSTR DomainName, IN GUID *DomainGuid, IN LPCSTR SiteName, IN ULONG Flags, OUT PDOMAIN_CONTROLLER_INFOA *DomainControllerInfo );
[DllImport(Lib.NetApi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("dsgetdc.h", MSDNShortId = "da8b2983-5e45-40b0-b552-c9b3a1d8ae94")]
public static extern Win32Error DsGetDcName([Optional] string ComputerName, [Optional] string DomainName, in Guid DomainGuid, [Optional] string SiteName, DsGetDcNameFlags Flags, out SafeNetApiBuffer DomainControllerInfo);
/// <summary>
/// The DsGetDcName function returns the name of a domain controller in a specified domain. This function accepts additional domain
@ -614,59 +920,7 @@ namespace Vanara.PInvoke
/// </returns>
[DllImport(Lib.NetApi32, CharSet = CharSet.Auto)]
[PInvokeData("DsGetDC.h", MSDNShortId = "ms675983")]
public static extern Win32Error DsGetDcName(string ComputerName, string DomainName, in Guid DomainGuid, string SiteName, DsGetDcNameFlags Flags, out SafeNetApiBuffer DomainControllerInfo);
/// <summary>
/// The DsGetDcName function returns the name of a domain controller in a specified domain. This function accepts additional domain
/// controller selection criteria to indicate preference for a domain controller with particular characteristics.
/// </summary>
/// <param name="ComputerName">
/// Pointer to a null-terminated string that specifies the name of the server to process this function. Typically, this parameter is
/// NULL, which indicates that the local computer is used.
/// </param>
/// <param name="DomainName">
/// Pointer to a null-terminated string that specifies the name of the domain or application partition to query. This name can either
/// be a DNS style name, for example, fabrikam.com, or a flat-style name, for example, Fabrikam. If a DNS style name is specified,
/// the name may be specified with or without a trailing period.
/// <para>
/// If the Flags parameter contains the DS_GC_SERVER_REQUIRED flag, DomainName must be the name of the forest. In this case,
/// DsGetDcName fails if DomainName specifies a name that is not the forest root.
/// </para>
/// <para>
/// If the Flags parameter contains the DS_GC_SERVER_REQUIRED flag and DomainName is NULL, DsGetDcName attempts to find a global
/// catalog in the forest of the computer identified by ComputerName, which is the local computer if ComputerName is NULL.
/// </para>
/// <para>
/// If DomainName is NULL and the Flags parameter does not contain the DS_GC_SERVER_REQUIRED flag, ComputerName is set to the default
/// domain name of the primary domain of the computer identified by ComputerName.
/// </para>
/// </param>
/// <param name="DomainGuid">
/// Pointer to a GUID structure that specifies the GUID of the domain queried. If DomainGuid is not NULL and the domain specified by
/// DomainName or ComputerName cannot be found, DsGetDcName attempts to locate a domain controller in the domain having the GUID
/// specified by DomainGuid.
/// </param>
/// <param name="SiteName">
/// Pointer to a null-terminated string that specifies the name of the site where the returned domain controller should physically
/// exist. If this parameter is NULL, DsGetDcName attempts to return a domain controller in the site closest to the site of the
/// computer specified by ComputerName. This parameter should be NULL, by default.
/// </param>
/// <param name="Flags">
/// Contains a set of flags that provide additional data used to process the request. This parameter can be a combination of the
/// following values.
/// </param>
/// <param name="DomainControllerInfo">
/// Pointer to a PDOMAIN_CONTROLLER_INFO value that receives a pointer to a DOMAIN_CONTROLLER_INFO structure that contains data about
/// the domain controller selected. This structure is allocated by DsGetDcName. The caller must free the structure using the
/// NetApiBufferFree function when it is no longer required.
/// </param>
/// <returns>
/// If the function returns domain controller data, the return value is ERROR_SUCCESS.
/// <para>If the function fails, the return value can be one of the following error codes.</para>
/// </returns>
[DllImport(Lib.NetApi32, CharSet = CharSet.Auto)]
[PInvokeData("DsGetDC.h", MSDNShortId = "ms675983")]
public static extern Win32Error DsGetDcName(string ComputerName, string DomainName, IntPtr DomainGuid, string SiteName, DsGetDcNameFlags Flags, out SafeNetApiBuffer DomainControllerInfo);
public static extern Win32Error DsGetDcName([Optional] string ComputerName, [Optional] string DomainName, [Optional] IntPtr DomainGuid, [Optional] string SiteName, DsGetDcNameFlags Flags, out SafeNetApiBuffer DomainControllerInfo);
/// <summary>
/// <para>The <c>DsGetDcNext</c> function retrieves the next domain controller in a domain controller enumeration operation.</para>
@ -1005,8 +1259,7 @@ namespace Vanara.PInvoke
/// </param>
/// <param name="SiteName">
/// <para>
/// Pointer to a variable that receives a pointer to a null-terminated string specifying the site location of this computer. This
/// string is allocated by the system and must be freed using the NetApiBufferFree function.
/// Pointer to a variable that receives a pointer to a null-terminated string specifying the site location of this computer.
/// </para>
/// </param>
/// <returns>
@ -1023,7 +1276,7 @@ namespace Vanara.PInvoke
// ComputerName, OUT LPSTR *SiteName );
[DllImport(Lib.NetApi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("dsgetdc.h", MSDNShortId = "2dfffd9a-af4f-4a93-8b3c-966e4f7c455f")]
public static extern Win32Error DsGetSiteName([Optional] string ComputerName, out SafeNetApiBuffer SiteName);
public static extern Win32Error DsGetSiteName([Optional] string ComputerName, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(NetApiBufferUnicodeStringMarshaler))] out string SiteName);
/// <summary>
/// <para>
@ -1290,7 +1543,7 @@ namespace Vanara.PInvoke
private SafeDCEnumHandle() : base() { }
/// <inheritdoc/>
protected override bool InternalReleaseHandle() { DsGetDcClose(this); return true; }
protected override bool InternalReleaseHandle() { DsGetDcClose(handle); return true; }
}
}
}

View File

@ -104,7 +104,7 @@ namespace Vanara.PInvoke
{
/// <summary>The DsRoleGetPrimaryDomainInformation function retrieves data from a DSROLE_PRIMARY_DOMAIN_INFO_BASIC structure.</summary>
[CorrespondingType(typeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC), CorrepsondingAction.Get)]
DsRolePrimaryDomainInfoBasic,
DsRolePrimaryDomainInfoBasic = 1,
/// <summary>The DsRoleGetPrimaryDomainInformation function retrieves from a DSROLE_UPGRADE_STATUS_INFO structure.</summary>
[CorrespondingType(typeof(DSROLE_UPGRADE_STATUS_INFO), CorrepsondingAction.Get)]
@ -147,25 +147,19 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/desktop/api/dsrole/nf-dsrole-dsrolefreememory void DsRoleFreeMemory( IN PVOID Buffer );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dsrole.h", MSDNShortId = "5560dfec-2134-4e02-9c87-26d246cd5841")]
public static extern void DsRoleFreeMemory(SafeDcRoleBuffer Buffer);
public static extern void DsRoleFreeMemory(IntPtr Buffer);
/// <summary>
/// <para>
/// The <c>DsRoleGetPrimaryDomainInformation</c> function retrieves state data for the computer. This data includes the state of the
/// directory service installation and domain data.
/// </para>
/// </summary>
/// <param name="lpServer">
/// <para>
/// Pointer to null-terminated Unicode string that contains the name of the computer on which to call the function. If this parameter
/// is <c>NULL</c>, the local computer is used.
/// </para>
/// </param>
/// <param name="InfoLevel">
/// <para>
/// Contains one of the DSROLE_PRIMARY_DOMAIN_INFO_LEVEL values that specify the type of data to retrieve. This parameter also
/// determines the format of the data supplied in Buffer.
/// </para>
/// </param>
/// <param name="Buffer">
/// <para>
@ -182,7 +176,7 @@ namespace Vanara.PInvoke
// DsRoleGetPrimaryDomainInformation( IN LPCWSTR lpServer, IN DSROLE_PRIMARY_DOMAIN_INFO_LEVEL InfoLevel, OUT PBYTE *Buffer );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dsrole.h", MSDNShortId = "d54876e3-a622-4b44-a597-db0f710f7758")]
public static extern uint DsRoleGetPrimaryDomainInformation([MarshalAs(UnmanagedType.LPWStr)] string lpServer, DSROLE_PRIMARY_DOMAIN_INFO_LEVEL InfoLevel, out SafeDcRoleBuffer Buffer);
public static extern Win32Error DsRoleGetPrimaryDomainInformation([In, MarshalAs(UnmanagedType.LPWStr), Optional] string lpServer, DSROLE_PRIMARY_DOMAIN_INFO_LEVEL InfoLevel, out SafeDcRoleBuffer Buffer);
/// <summary>
/// <para>
@ -314,7 +308,7 @@ namespace Vanara.PInvoke
public T ToStructure<T>() where T : struct => IsInvalid ? default : (T)Marshal.PtrToStructure(handle, typeof(T));
/// <inheritdoc/>
protected override bool InternalReleaseHandle() { DsRoleFreeMemory(this); return true; }
protected override bool InternalReleaseHandle() { DsRoleFreeMemory(handle); return true; }
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,124 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
using Vanara.Extensions;
namespace Vanara.PInvoke
{
public static partial class NetApi32
{
/*
GROUP_INFO_0 structure
GROUP_INFO_1 structure
GROUP_INFO_1002 structure
GROUP_INFO_1005 structure
GROUP_INFO_2 structure
GROUP_INFO_3 structure
GROUP_USERS_INFO_0 structure
GROUP_USERS_INFO_1 structure
LOCALGROUP_INFO_0 structure
LOCALGROUP_INFO_1 structure
LOCALGROUP_INFO_1002 structure
LOCALGROUP_MEMBERS_INFO_0 structure
LOCALGROUP_MEMBERS_INFO_1 structure
LOCALGROUP_MEMBERS_INFO_2 structure
LOCALGROUP_MEMBERS_INFO_3 structure
LOCALGROUP_USERS_INFO_0 structure
NET_DISPLAY_GROUP structure
NET_DISPLAY_MACHINE structure
NET_DISPLAY_USER structure
NET_VALIDATE_AUTHENTICATION_INPUT_ARG structure
NET_VALIDATE_OUTPUT_ARG structure
NET_VALIDATE_PASSWORD_CHANGE_INPUT_ARG structure
NET_VALIDATE_PASSWORD_HASH structure
NET_VALIDATE_PASSWORD_RESET_INPUT_ARG structure
NET_VALIDATE_PERSISTED_FIELDS structure
USER_INFO_0 structure
USER_INFO_1 structure
USER_INFO_10 structure
USER_INFO_1003 structure
USER_INFO_1005 structure
USER_INFO_1006 structure
USER_INFO_1007 structure
USER_INFO_1008 structure
USER_INFO_1009 structure
USER_INFO_1010 structure
USER_INFO_1011 structure
USER_INFO_1012 structure
USER_INFO_1013 structure
USER_INFO_1014 structure
USER_INFO_1017 structure
USER_INFO_1018 structure
USER_INFO_1020 structure
USER_INFO_1023 structure
USER_INFO_1024 structure
USER_INFO_1025 structure
USER_INFO_1051 structure
USER_INFO_1052 structure
USER_INFO_1053 structure
USER_INFO_11 structure
USER_INFO_2 structure
USER_INFO_20 structure
USER_INFO_21 structure
USER_INFO_22 structure
USER_INFO_23 structure
USER_INFO_24 structure
USER_INFO_3 structure
USER_INFO_4 structure
USER_MODALS_INFO_0 structure
USER_MODALS_INFO_1 structure
USER_MODALS_INFO_1001 structure
USER_MODALS_INFO_1002 structure
USER_MODALS_INFO_1003 structure
USER_MODALS_INFO_1004 structure
USER_MODALS_INFO_1005 structure
USER_MODALS_INFO_1006 structure
USER_MODALS_INFO_1007 structure
USER_MODALS_INFO_2 structure
USER_MODALS_INFO_3 structure
NetAccessAdd function
NetAccessDel function
NetAccessEnum function
NetAccessGetInfo function
NetAccessGetUserPerms function
NetAccessSetInfo function
NetGetAnyDCName function
NetGetDCName function
NetGetDisplayInformationIndex function
NetGroupAdd function
NetGroupAddUser function
NetGroupDel function
NetGroupDelUser function
NetGroupEnum function
NetGroupGetInfo function
NetGroupGetUsers function
NetGroupSetInfo function
NetGroupSetUsers function
NetLocalGroupAdd function
NetLocalGroupAddMember function
NetLocalGroupAddMembers function
NetLocalGroupDel function
NetLocalGroupDelMember function
NetLocalGroupDelMembers function
NetLocalGroupEnum function
NetLocalGroupGetInfo function
NetLocalGroupGetMembers function
NetLocalGroupSetInfo function
NetLocalGroupSetMembers function
NetQueryDisplayInformation function
NetUserAdd function
NetUserChangePassword function
NetUserDel function
NetUserEnum function
NetUserGetGroups function
NetUserGetInfo function
NetUserGetLocalGroups function
NetUserModalsGet function
NetUserModalsSet function
NetUserSetGroups function
NetUserSetInfo function
NetValidatePasswordPolicy function
NetValidatePasswordPolicyFree function
*/
}
}

628
PInvoke/NetApi32/LmAlert.cs Normal file
View File

@ -0,0 +1,628 @@
using System;
using System.Runtime.InteropServices;
using Vanara.Extensions;
namespace Vanara.PInvoke
{
public static partial class NetApi32
{
/// <summary>An administrator's intervention is required.</summary>
public const string ALERT_ADMIN_EVENT = "ADMIN";
/// <summary>An entry was added to the error log.</summary>
public const string ALERT_ERRORLOG_EVENT = "ERRORLOG";
/// <summary>A user or application received a broadcast message.</summary>
public const string ALERT_MESSAGE_EVENT = "MESSAGE";
/// <summary>A print job completed or a print error occurred.</summary>
public const string ALERT_PRINT_EVENT = "PRINTING";
/// <summary>An application or resource was used.</summary>
public const string ALERT_USER_EVENT = "USER";
/// <summary>Name of mailslot to send alert notifications</summary>
public const string ALERTER_MAILSLOT = "\\\\.\\MAILSLOT\\Alerter";
/// <summary>A bitmask describing the status of the print job.</summary>
[PInvokeData("lmalert.h", MSDNShortId = "f2fd87bc-abde-43c0-b29d-d43cc5f038b8")]
[Flags]
public enum PRJOB
{
/// <summary>The print job is in the queue waiting to be scheduled.</summary>
PRJOB_QS_QUEUED = 0,
/// <summary>The print job is in the queue, but it has been paused. (When a job is paused, it cannot be scheduled.)</summary>
PRJOB_QS_PAUSED = 1,
/// <summary>The print job is in the process of being spooled.</summary>
PRJOB_QS_SPOOLING = 2,
/// <summary>The job is currently printing.</summary>
PRJOB_QS_PRINTING = 3,
/// <summary>The job has completed printing.</summary>
PRJOB_COMPLETE = 0x4,
/// <summary>The destination printer requires an operator's intervention.</summary>
PRJOB_INTERV = 0x8,
/// <summary>There is an error at the destination printer.</summary>
PRJOB_ERROR = 0x10,
/// <summary>The destination printer is offline.</summary>
PRJOB_DESTOFFLINE = 0x20,
/// <summary>The destination printer is paused.</summary>
PRJOB_DESTPAUSED = 0x40,
/// <summary>A printing alert should be raised.</summary>
PRJOB_NOTIFY = 0x80,
/// <summary>The destination printer is out of paper.</summary>
PRJOB_DESTNOPAPER = 0x100,
/// <summary>The printing job is being deleted.</summary>
PRJOB_DELETED = 0x8000,
}
/// <summary>
/// The <c>ALERT_OTHER_INFO</c> macro returns a pointer to the alert-specific data in an alert message. The data follows a STD_ALERT
/// structure, and can be an ADMIN_OTHER_INFO, a PRINT_OTHER_INFO, or a USER_OTHER_INFO structure.
/// </summary>
/// <param name="x">Pointer to a <c>STD_ALERT</c> structure that was specified in a call to the NetAlertRaise function.</param>
/// <remarks>
/// <para>The <c>ALERT_OTHER_INFO</c> macro is defined as follows:</para>
/// <para>
/// See NetAlertRaise for a code sample that uses the <c>ALERT_OTHER_INFO</c> macro to retrieve a pointer to the
/// <c>ADMIN_OTHER_INFO</c> structure.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmalert/nf-lmalert-alert_other_info void ALERT_OTHER_INFO( x );
[PInvokeData("lmalert.h", MSDNShortId = "e7bcc306-4b44-4230-96aa-a4717bb1fb11")]
public static IntPtr ALERT_OTHER_INFO(IntPtr x) => x.Offset(Marshal.SizeOf(typeof(STD_ALERT)));
/// <summary>
/// The <c>ALERT_VAR_DATA</c> macro returns a pointer to the variable-length portion of an alert message. Variable-length data can
/// follow an ADMIN_OTHER_INFO, a PRINT_OTHER_INFO, or a USER_OTHER_INFO structure.
/// </summary>
/// <param name="p">
/// Pointer to an <c>ADMIN_OTHER_INFO</c>, a <c>PRINT_OTHER_INFO</c>, or a <c>USER_OTHER_INFO</c> structure that was specified in a
/// call to the NetAlertRaise function or the NetAlertRaiseEx function.
/// </param>
/// <remarks>
/// <para>The <c>ALERT_VAR_DATA</c> macro is defined as follows:</para>
/// <para>
/// See NetAlertRaise and NetAlertRaiseEx for code samples that use the <c>ALERT_VAR_DATA</c> macro to retrieve a pointer to the
/// variable-length data in an alert message.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmalert/nf-lmalert-alert_var_data void ALERT_VAR_DATA( p );
[PInvokeData("lmalert.h", MSDNShortId = "ff71fb3d-8c01-47ac-93f2-108b1f49e2da")]
public static IntPtr ALERT_VAR_DATA<T>(IntPtr p) where T : struct => p.Offset(Marshal.SizeOf(typeof(T)));
/// <summary>
/// <para>[This function is not supported as of Windows Vista because the alerter service is not supported.]</para>
/// <para>The <c>NetAlertRaise</c> function notifies all registered clients when a particular event occurs.</para>
/// <para>
/// To simplify sending an alert message, you can call the extended function NetAlertRaiseEx instead. <c>NetAlertRaiseEx</c> does not
/// require that you specify a STD_ALERT structure.
/// </para>
/// </summary>
/// <param name="AlertType">
/// <para>
/// A pointer to a constant string that specifies the alert class (type of alert) to raise. This parameter can be one of the
/// following predefined values, or a user-defined alert class for network applications. The event name for an alert can be any text string.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Name</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>ALERT_ADMIN_EVENT</term>
/// <term>An administrator's intervention is required.</term>
/// </item>
/// <item>
/// <term>ALERT_ERRORLOG_EVENT</term>
/// <term>An entry was added to the error log.</term>
/// </item>
/// <item>
/// <term>ALERT_MESSAGE_EVENT</term>
/// <term>A user or application received a broadcast message.</term>
/// </item>
/// <item>
/// <term>ALERT_PRINT_EVENT</term>
/// <term>A print job completed or a print error occurred.</term>
/// </item>
/// <item>
/// <term>ALERT_USER_EVENT</term>
/// <term>An application or resource was used.</term>
/// </item>
/// </list>
/// </param>
/// <param name="Buffer">
/// <para>
/// A pointer to the data to send to the clients listening for the interrupting message. The data should begin with a fixed-length
/// STD_ALERT structure followed by additional message data in one ADMIN_OTHER_INFO, ERRLOG_OTHER_INFO, PRINT_OTHER_INFO, or
/// USER_OTHER_INFO structure. Finally, the buffer should include any required variable-length information. For more information, see
/// the code sample in the following Remarks section.
/// </para>
/// <para>
/// The calling application must allocate and free the memory for all structures and variable data. For more information, see Network
/// Management Function Buffers.
/// </para>
/// </param>
/// <param name="BufferSize">The size, in bytes, of the message buffer.</param>
/// <returns>
/// <para>If the function succeeds, the return value is NERR_Success.</para>
/// <para>
/// If the function fails, the return value is a system error code and a can be one of the following error codes. For a list of all
/// possible error codes, see System Error Codes.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>ERROR_INVALID_PARAMETER</term>
/// <term>
/// A parameter is incorrect. This error is returned if the AlertEventName parameter is NULL or an empty string, the Buffer parameter
/// is NULL, or the BufferSize parameter is less than the size of the STD_ALERT structure plus the fixed size for the additional
/// message data structure.
/// </term>
/// </item>
/// <item>
/// <term>ERROR_NOT_SUPPORTED</term>
/// <term>The request is not supported. This error is returned on Windows Vista and later since the Alerter service is not supported.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>No special group membership is required to successfully execute the <c>NetAlertRaise</c> function.</para>
/// <para>
/// The alerter service must be running on the client computer when you call the <c>NetAlertRaise</c> function, or the function fails
/// with ERROR_FILE_NOT_FOUND.
/// </para>
/// <para>Examples</para>
/// <para>
/// The following code sample demonstrates how to raise an administrative alert by calling the <c>NetAlertRaise</c> function and
/// specifying STD_ALERT and ADMIN_OTHER_INFO structures. First, the sample calculates the size of the message buffer. Then it
/// allocates the buffer with a call to the GlobalAlloc function. The code assigns values to the members of the <c>STD_ALERT</c> and
/// the <c>ADMIN_OTHER_INFO</c> portions of the buffer. The sample retrieves a pointer to the <c>ADMIN_OTHER_INFO</c> structure by
/// calling the ALERT_OTHER_INFO macro. It also retrieves a pointer to the variable data portion of the buffer by calling the
/// ALERT_VAR_DATA macro. Finally, the code sample frees the memory allocated for the buffer with a call to the GlobalFree function.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmalert/nf-lmalert-netalertraise NET_API_STATUS NET_API_FUNCTION
// NetAlertRaise( LPCWSTR AlertType, LPVOID Buffer, DWORD BufferSize );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("lmalert.h", MSDNShortId = "11367a72-c21d-4044-98cf-a7a30cc43a8b")]
public static extern Win32Error NetAlertRaise([MarshalAs(UnmanagedType.LPWStr)] string AlertType, IntPtr Buffer, uint BufferSize);
/// <summary>
/// <para>[This function is not supported as of Windows Vista because the alerter service is not supported.]</para>
/// <para>
/// The <c>NetAlertRaiseEx</c> function notifies all registered clients when a particular event occurs. You can call this extended
/// function to simplify the sending of an alert message because <c>NetAlertRaiseEx</c> does not require that you specify a STD_ALERT structure.
/// </para>
/// </summary>
/// <param name="AlertType">
/// <para>
/// A pointer to a constant string that specifies the alert class (type of alert) to raise. This parameter can be one of the
/// following predefined values, or a user-defined alert class for network applications. (The event name for an alert can be any text string.)
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Name</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>ALERT_ADMIN_EVENT</term>
/// <term>An administrator's intervention is required.</term>
/// </item>
/// <item>
/// <term>ALERT_ERRORLOG_EVENT</term>
/// <term>An entry was added to the error log.</term>
/// </item>
/// <item>
/// <term>ALERT_MESSAGE_EVENT</term>
/// <term>A user or application received a broadcast message.</term>
/// </item>
/// <item>
/// <term>ALERT_PRINT_EVENT</term>
/// <term>A print job completed or a print error occurred.</term>
/// </item>
/// <item>
/// <term>ALERT_USER_EVENT</term>
/// <term>An application or resource was used.</term>
/// </item>
/// </list>
/// </param>
/// <param name="VariableInfo">
/// <para>
/// A pointer to the data to send to the clients listening for the interrupting message. The data should consist of one
/// ADMIN_OTHER_INFO, ERRLOG_OTHER_INFO, PRINT_OTHER_INFO, or USER_OTHER_INFO structure followed by any required variable-length
/// information. For more information, see the code sample in the following Remarks section.
/// </para>
/// <para>
/// The calling application must allocate and free the memory for all structures and variable data. For more information, see Network
/// Management Function Buffers.
/// </para>
/// </param>
/// <param name="VariableInfoSize">The number of bytes of variable information in the buffer pointed to by the VariableInfo parameter.</param>
/// <param name="ServiceName">A pointer to a constant string that specifies the name of the service raising the interrupting message.</param>
/// <returns>
/// <para>If the function succeeds, the return value is NERR_Success.</para>
/// <para>
/// If the function fails, the return value is a system error code and a can be one of the following error codes. For a list of all
/// possible error codes, see System Error Codes.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>ERROR_INVALID_PARAMETER</term>
/// <term>
/// A parameter is incorrect. This error is returned if the AlertEventName parameter is NULL or an empty string, the ServiceName
/// parameter is NULL or an empty string, the VariableInfo parameter is NULL, or the VariableInfoSize parameter is greater than 512
/// minus the size of the STD_ALERT structure.
/// </term>
/// </item>
/// <item>
/// <term>ERROR_NOT_SUPPORTED</term>
/// <term>The request is not supported. This error is returned on Windows Vista and later since the Alerter service is not supported.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>No special group membership is required to successfully execute the <c>NetAlertRaiseEx</c> function.</para>
/// <para>
/// The alerter service must be running on the client computer when you call the <c>NetAlertRaiseEx</c> function, or the function
/// fails with ERROR_FILE_NOT_FOUND.
/// </para>
/// <para>Examples</para>
/// <para>
/// The following code sample demonstrates how to raise the following types of interrupting messages (alerts) by calling the
/// <c>NetAlertRaiseEx</c> function:
/// </para>
/// <list type="bullet">
/// <item>
/// <term>An administrative alert by specifying an ADMIN_OTHER_INFO structure</term>
/// </item>
/// <item>
/// <term>A print alert by specifying a PRINT_OTHER_INFO structure</term>
/// </item>
/// <item>
/// <term>A user alert by specifying a USER_OTHER_INFO structure</term>
/// </item>
/// </list>
/// <para>
/// In each instance the code assigns values to the members of the relevant alert information structure. Following this, the sample
/// retrieves a pointer to the portion of the message buffer that follows the structure by calling the ALERT_VAR_DATA macro. The code
/// also fills in the variable-length strings in this portion of the buffer. Finally, the sample calls <c>NetAlertRaiseEx</c> to send
/// the alert.
/// </para>
/// <para>
/// Note that the calling application must allocate and free the memory for all structures and variable-length data in an alert
/// message buffer.
/// </para>
/// <para>
/// To pass a user-defined structure and valid strings in a user alert, you must create an event message file and link it with your
/// application. You must also register the application in the <c>EventMessageFile</c> subkey in the <c>EventLog</c> section of the
/// registry. If you do not register the application, the user alert will contain the information you pass in the variable-length
/// strings that follow the USER_OTHER_INFO structure. For more information about <c>EventMessageFile</c>, see Event Logging.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmalert/nf-lmalert-netalertraiseex NET_API_STATUS NET_API_FUNCTION
// NetAlertRaiseEx( LPCWSTR AlertType, LPVOID VariableInfo, DWORD VariableInfoSize, LPCWSTR ServiceName );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("lmalert.h", MSDNShortId = "9762f0d6-0022-4e05-b2d8-6223d7bbb2c8")]
public static extern Win32Error NetAlertRaiseEx([MarshalAs(UnmanagedType.LPWStr)] string AlertType, IntPtr VariableInfo, uint VariableInfoSize, [MarshalAs(UnmanagedType.LPWStr)] string ServiceName);
/// <summary>
/// The <c>ADMIN_OTHER_INFO</c> structure contains error message information. The NetAlertRaise and NetAlertRaiseEx functions use the
/// <c>ADMIN_OTHER_INFO</c> structure to specify information when raising an administrator's interrupting message.
/// </summary>
/// <remarks>
/// <para>
/// Variable-length data follows the <c>ADMIN_OTHER_INFO</c> structure in the alert message buffer if you specify one or more strings
/// in the <c>alrtad_numstrings</c> member. The calling application must allocate and free the memory for all structures and
/// variable-length data in an alert message buffer.
/// </para>
/// <para>See NetAlertRaise and NetAlertRaiseEx for code samples that demonstrate how to raise an administrative alert.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmalert/ns-lmalert-_admin_other_info typedef struct _ADMIN_OTHER_INFO { DWORD
// alrtad_errcode; DWORD alrtad_numstrings; } ADMIN_OTHER_INFO, *PADMIN_OTHER_INFO, *LPADMIN_OTHER_INFO;
[PInvokeData("lmalert.h", MSDNShortId = "43119dcf-7d04-4e3b-b1dc-20e814fbdc2f")]
[StructLayout(LayoutKind.Sequential)]
public struct ADMIN_OTHER_INFO
{
/// <summary>Specifies the error code for the new message written to the message log.</summary>
public uint alrtad_errcode;
/// <summary>Specifies the number (0-9) of consecutive Unicode strings written to the message log.</summary>
public uint alrtad_numstrings;
}
/// <summary>
/// The <c>ERRLOG_OTHER_INFO</c> structure contains error log information. The NetAlertRaise and NetAlertRaiseEx functions use the
/// <c>ERRLOG_OTHER_INFO</c> structure to specify information when adding a new entry to the error log.
/// </summary>
/// <remarks>
/// The calling application must allocate and free the memory for all structures and variable-length data in an alert message buffer.
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmalert/ns-lmalert-_errlog_other_info typedef struct _ERRLOG_OTHER_INFO {
// DWORD alrter_errcode; DWORD alrter_offset; } ERRLOG_OTHER_INFO, *PERRLOG_OTHER_INFO, *LPERRLOG_OTHER_INFO;
[PInvokeData("lmalert.h", MSDNShortId = "832ebe88-e1c4-4ce3-8057-922419b577f7")]
[StructLayout(LayoutKind.Sequential)]
public struct ERRLOG_OTHER_INFO
{
/// <summary>Specifies the error code that was written to the error log.</summary>
public uint alrter_errcode;
/// <summary>Specifies the offset for the new entry in the error log.</summary>
public uint alrter_offset;
}
/// <summary>
/// The <c>PRINT_OTHER_INFO</c> structure contains information about a print job. The NetAlertRaise and NetAlertRaiseEx functions use
/// the <c>PRINT_OTHER_INFO</c> structure to specify information when a job has finished printing, or when a printer needs intervention.
/// </summary>
/// <remarks>
/// <para>
/// Additional variable-length data follows the <c>PRINT_OTHER_INFO</c> structure in the alert message buffer. The information is in
/// the form of contiguous null-terminated character strings, as follows.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>String</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>computername</term>
/// <term>The computer that submitted the print job.</term>
/// </item>
/// <item>
/// <term>username</term>
/// <term>The user who submitted the print job.</term>
/// </item>
/// <item>
/// <term>queuename</term>
/// <term>The print queue to which the job was submitted.</term>
/// </item>
/// <item>
/// <term>destination</term>
/// <term>The printer destination (device) to which the print job was routed.</term>
/// </item>
/// <item>
/// <term>status</term>
/// <term>The status of the print job.</term>
/// </item>
/// </list>
/// <para>
/// The calling application must allocate and free the memory for all structures and variable-length data in an alert message buffer.
/// </para>
/// <para>See NetAlertRaiseEx for a code sample that demonstrates how to raise a print alert.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmalert/ns-lmalert-_print_other_info typedef struct _PRINT_OTHER_INFO { DWORD
// alrtpr_jobid; DWORD alrtpr_status; DWORD alrtpr_submitted; DWORD alrtpr_size; } PRINT_OTHER_INFO, *PPRINT_OTHER_INFO, *LPPRINT_OTHER_INFO;
[PInvokeData("lmalert.h", MSDNShortId = "f2fd87bc-abde-43c0-b29d-d43cc5f038b8")]
[StructLayout(LayoutKind.Sequential)]
public struct PRINT_OTHER_INFO
{
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>The identification number of the print job.</para>
/// </summary>
public uint alrtpr_jobid;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>A bitmask describing the status of the print job.</para>
/// <para>You can obtain the overall status of the job by checking PRJOB_QSTATUS (bits 0 and 1).</para>
/// <para>Possible values for the print job status are listed in the Lmalert.h header file.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>PRJOB_QS_QUEUED 0</term>
/// <term>The print job is in the queue waiting to be scheduled.</term>
/// </item>
/// <item>
/// <term>PRJOB_QS_PAUSED 1</term>
/// <term>The print job is in the queue, but it has been paused. (When a job is paused, it cannot be scheduled.)</term>
/// </item>
/// <item>
/// <term>PRJOB_QS_SPOOLING 2</term>
/// <term>The print job is in the process of being spooled.</term>
/// </item>
/// <item>
/// <term>PRJOB_QS_PRINTING 3</term>
/// <term>The job is currently printing.</term>
/// </item>
/// </list>
/// <para>
/// If the print job is in the PRJOB_QS_PRINTING state, you can check bits 2 through 8 for the device's status (PRJOB_DEVSTATUS).
/// Bit 15 is also meaningful.
/// </para>
/// <para>Possible values for the device's status are listed in the Lmalert.h header file.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>PRJOB_COMPLETE 0x4</term>
/// <term>The job has completed printing.</term>
/// </item>
/// <item>
/// <term>PRJOB_INTERV 0x8</term>
/// <term>The destination printer requires an operator's intervention.</term>
/// </item>
/// <item>
/// <term>PRJOB_ERROR 0x10</term>
/// <term>There is an error at the destination printer.</term>
/// </item>
/// <item>
/// <term>PRJOB_DESTOFFLINE 0x20</term>
/// <term>The destination printer is offline.</term>
/// </item>
/// <item>
/// <term>PRJOB_DESTPAUSED 0x40</term>
/// <term>The destination printer is paused.</term>
/// </item>
/// <item>
/// <term>PRJOB_NOTIFY 0x80</term>
/// <term>A printing alert should be raised.</term>
/// </item>
/// <item>
/// <term>PRJOB_DESTNOPAPER 0x100</term>
/// <term>The destination printer is out of paper.</term>
/// </item>
/// <item>
/// <term>PRJOB_DELETED 0x8000</term>
/// <term>The printing job is being deleted.</term>
/// </item>
/// </list>
/// </summary>
public PRJOB alrtpr_status;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>
/// The time at which the print job was submitted. This value is stored as the number of seconds that have elapsed since
/// 00:00:00, January 1, 1970, GMT.
/// </para>
/// </summary>
public uint alrtpr_submitted;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>The size, in bytes, of the print job.</para>
/// </summary>
public uint alrtpr_size;
}
/// <summary>
/// The <c>STD_ALERT</c> structure contains the time and date when a significant event occurred. The structure also contains an alert
/// class and the name of the application that is raising the alert message. You must specify the <c>STD_ALERT</c> structure when you
/// send an alert message using the NetAlertRaise function.
/// </summary>
/// <remarks>
/// <para>
/// The <c>STD_ALERT</c> structure must be followed by one ADMIN_OTHER_INFO, ERRLOG_OTHER_INFO, PRINT_OTHER_INFO, or USER_OTHER_INFO
/// structure. These structures can optionally be followed by variable-length data. The calling application must allocate the memory
/// for all structures and variable-length data in an alert message buffer.
/// </para>
/// <para>
/// See NetAlertRaise for a code sample that raises an administrative alert using a <c>STD_ALERT</c> structure and an
/// ADMIN_OTHER_INFO structure.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmalert/ns-lmalert-_std_alert typedef struct _STD_ALERT { DWORD
// alrt_timestamp; WCHAR alrt_eventname[EVLEN + 1]; WCHAR alrt_servicename[SNLEN + 1]; } STD_ALERT, *PSTD_ALERT, *LPSTD_ALERT;
[PInvokeData("lmalert.h", MSDNShortId = "daa4594f-e59e-4f05-8183-677bee4ea446")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct STD_ALERT
{
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>
/// The time and date of the event. This value is stored as the number of seconds that have elapsed since 00:00:00, January 1,
/// 1970, GMT.
/// </para>
/// </summary>
public uint alrt_timestamp;
/// <summary>
/// <para>Type: <c>WCHAR[EVLEN + 1]</c></para>
/// <para>
/// A Unicode string indicating the alert class (type of event). This parameter can be one of the following predefined values, or
/// another alert class that you have defined for network applications. (The event name for an alert can be any text string.)
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Name</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>ALERT_ADMIN_EVENT</term>
/// <term>An administrator's intervention is required.</term>
/// </item>
/// <item>
/// <term>ALERT_ERRORLOG_EVENT</term>
/// <term>An entry was added to the error log.</term>
/// </item>
/// <item>
/// <term>ALERT_MESSAGE_EVENT</term>
/// <term>A user or application received a broadcast message.</term>
/// </item>
/// <item>
/// <term>ALERT_PRINT_EVENT</term>
/// <term>A print job completed or a print error occurred.</term>
/// </item>
/// <item>
/// <term>ALERT_USER_EVENT</term>
/// <term>An application or resource was used.</term>
/// </item>
/// </list>
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 17)]
public string alrt_eventname;
/// <summary>
/// <para>Type: <c>WCHAR[SNLEN + 1]</c></para>
/// <para>A Unicode string indicating the service application that is raising the alert message.</para>
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 81)]
public string alrt_servicename;
}
/// <summary>
/// The <c>USER_OTHER_INFO</c> structure contains user error code information. The NetAlertRaise and NetAlertRaiseEx functions use
/// the <c>USER_OTHER_INFO</c> structure to specify information about an event or condition of interest to a user.
/// </summary>
/// <remarks>
/// <para>
/// Additional variable-length data follows the <c>USER_OTHER_INFO</c> structure in the alert message buffer. The information is in
/// the form of contiguous null-terminated character strings, as follows.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>String</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>username</term>
/// <term>The user who created the session.</term>
/// </item>
/// <item>
/// <term>computername</term>
/// <term>The computer that created the session.</term>
/// </item>
/// </list>
/// <para>
/// The calling application must allocate and free the memory for all structures and variable-length data in an alert message buffer.
/// </para>
/// <para>See NetAlertRaiseEx for a code sample that demonstrates how to raise a user alert.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmalert/ns-lmalert-_user_other_info typedef struct _USER_OTHER_INFO { DWORD
// alrtus_errcode; DWORD alrtus_numstrings; } USER_OTHER_INFO, *PUSER_OTHER_INFO, *LPUSER_OTHER_INFO;
[PInvokeData("lmalert.h", MSDNShortId = "2f6bd906-fdab-410a-8856-4482e047371f")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct USER_OTHER_INFO
{
/// <summary>Specifies the error code for the new message in the message log.</summary>
public uint alrtus_errcode;
/// <summary>Specifies the number (0-9) of consecutive Unicode strings in the message log.</summary>
public uint alrtus_numstrings;
}
}
}

View File

@ -0,0 +1,176 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Security;
using Vanara.Extensions;
namespace Vanara.PInvoke
{
public static partial class NetApi32
{
/// <summary>
/// The <c>NetApiBufferAllocate</c> function allocates memory from the heap. Use this function only when compatibility with the
/// NetApiBufferFree function is required. Otherwise, use the memory management functions.
/// </summary>
/// <param name="ByteCount">Number of bytes to be allocated.</param>
/// <param name="Buffer">Receives a pointer to the allocated buffer.</param>
/// <returns>
/// <para>If the function succeeds, the return value is NERR_Success.</para>
/// <para>If the function fails, the return value is a system error code. For a list of error codes, see System Error Codes.</para>
/// </returns>
/// <remarks>
/// <para>No special group membership is required to successfully execute the ApiBuffer functions.</para>
/// <para>For more information, see Network Management Function Buffers and Network Management Function Buffer Lengths.</para>
/// <para>Examples</para>
/// <para>The following code sample demonstrates how to use the network management ApiBuffer functions.</para>
/// <para>
/// The sample first calls the <c>NetApiBufferAllocate</c> function to allocate memory and then the NetApiBufferSize function to
/// retrieve the size of the allocated memory. Following this, the sample calls NetApiBufferReallocate to change the size of the
/// memory allocation. Finally, the sample calls NetApiBufferFree to free the memory. In each case, the sample prints a message
/// indicating success or failure.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmapibuf/nf-lmapibuf-netapibufferallocate NET_API_STATUS NET_API_FUNCTION
// NetApiBufferAllocate( DWORD ByteCount, LPVOID *Buffer );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("lmapibuf.h", MSDNShortId = "9ff1e3eb-9417-469f-a8c0-cdcda3cd9583")]
public static extern Win32Error NetApiBufferAllocate(uint ByteCount, out SafeNetApiBuffer Buffer);
/// <summary>
/// The NetApiBufferFree function frees the memory that the NetApiBufferAllocate function allocates. Applications should also call
/// NetApiBufferFree to free the memory that other network management functions use internally to return information.
/// </summary>
/// <param name="pBuf">
/// A pointer to a buffer returned previously by another network management function or memory allocated by calling the
/// NetApiBufferAllocate function.
/// </param>
/// <returns>
/// If the function succeeds, the return value is NERR_Success. If the function fails, the return value is a system error code.
/// </returns>
[DllImport(Lib.NetApi32, ExactSpelling = true), SuppressUnmanagedCodeSecurity]
[PInvokeData("lm.h", MSDNShortId = "aa370304")]
public static extern Win32Error NetApiBufferFree(IntPtr pBuf);
/// <summary>
/// The <c>NetApiBufferReallocate</c> function changes the size of a buffer allocated by a previous call to the NetApiBufferAllocate function.
/// </summary>
/// <param name="OldBuffer">Pointer to the buffer returned by a call to the NetApiBufferAllocate function.</param>
/// <param name="NewByteCount">Specifies the new size of the buffer, in bytes.</param>
/// <param name="NewBuffer">Receives the pointer to the reallocated buffer.</param>
/// <returns>
/// <para>If the function succeeds, the return value is NERR_Success.</para>
/// <para>If the function fails, the return value is a system error code. For a list of error codes, see System Error Codes.</para>
/// </returns>
/// <remarks>
/// <para>No special group membership is required to successfully execute the ApiBuffer functions.</para>
/// <para>For a code sample that demonstrates how to use the network management ApiBuffer functions, see NetApiBufferAllocate.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmapibuf/nf-lmapibuf-netapibufferreallocate NET_API_STATUS NET_API_FUNCTION
// NetApiBufferReallocate( _Frees_ptr_opt_ LPVOID OldBuffer, DWORD NewByteCount, LPVOID *NewBuffer );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("lmapibuf.h", MSDNShortId = "61153de0-33d3-4c83-a8aa-a7179252328c")]
public static extern Win32Error NetApiBufferReallocate(IntPtr OldBuffer, uint NewByteCount, out IntPtr NewBuffer);
/// <summary>
/// The <c>NetApiBufferSize</c> function returns the size, in bytes, of a buffer allocated by a call to the NetApiBufferAllocate function.
/// </summary>
/// <param name="Buffer">Pointer to a buffer returned by the NetApiBufferAllocate function.</param>
/// <param name="ByteCount">Receives the size of the buffer, in bytes.</param>
/// <returns>
/// <para>If the function succeeds, the return value is NERR_Success.</para>
/// <para>If the function fails, the return value is a system error code. For a list of error codes, see System Error Codes.</para>
/// </returns>
/// <remarks>
/// <para>No special group membership is required to successfully execute the ApiBuffer functions.</para>
/// <para>For a code sample that demonstrates how to use the network management ApiBuffer functions, see NetApiBufferAllocate.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmapibuf/nf-lmapibuf-netapibuffersize NET_API_STATUS NET_API_FUNCTION
// NetApiBufferSize( LPVOID Buffer, LPDWORD ByteCount );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("lmapibuf.h", MSDNShortId = "0c28feeb-00a3-4ad5-b85f-96326515fae2")]
public static extern Win32Error NetApiBufferSize(IntPtr Buffer, out uint ByteCount);
/// <summary>Provides a <see cref="SafeHandle"/> to a buffer that releases a created handle at disposal using NetApiBufferFree.</summary>
public class SafeNetApiBuffer : SafeHANDLE
{
/// <summary>Initializes a new instance of the <see cref="SafeNetApiBuffer"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle">
/// <see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).
/// </param>
public SafeNetApiBuffer(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
/// <summary>Initializes a new instance of the <see cref="SafeNetApiBuffer"/> class.</summary>
private SafeNetApiBuffer() : base() { }
/// <summary>
/// Gets or sets the size of the buffer in bytes. When setting, this reallocates the existing buffer and does not guarantee that
/// the currently allocated memory will be untouched or destroyed.
/// </summary>
/// <value>The size of the allocated memory in bytes.</value>
public uint Size
{
get { var err = NetApiBufferSize(handle, out var sz); return err.Succeeded ? sz : throw err.GetException(); }
set { NetApiBufferReallocate(handle, value, out var h).ThrowIfFailed(); SetHandle(h); }
}
/// <summary>Allocates memory for a new <see cref="SafeNetApiBuffer"/>.</summary>
/// <param name="size">The size of the buffer in bytes.</param>
/// <returns>A new instance of <see cref="SafeNetApiBuffer"/> with the requested number of bytes allocated.</returns>
public static SafeNetApiBuffer Allocate(uint size)
{
NetApiBufferAllocate(size, out var b).ThrowIfFailed();
return b;
}
/// <summary>Extracts a list of structures.</summary>
/// <typeparam name="T">The type of the structure.</typeparam>
/// <param name="count">The count of structures in the list.</param>
/// <returns>The list of structures.</returns>
public IEnumerable<T> ToIEnum<T>(int count) => handle.ToIEnum<T>(count);
/// <inheritdoc/>
public override string ToString() => Extensions.StringHelper.GetString(handle);
/// <summary>Extracts a list of strings. Used by <see cref="DsAddressToSiteNames"/>.</summary>
/// <param name="count">The number of elements in the list.</param>
/// <returns>The list of strings.</returns>
public IEnumerable<string> ToStringEnum(int count) => handle.ToStringEnum(count);
/// <summary>Returns an extracted structure from this buffer.</summary>
/// <typeparam name="T">The structure type to extract.</typeparam>
/// <returns>Extracted structure or default(T) if the buffer is invalid.</returns>
public T ToStructure<T>() where T : struct => IsInvalid ? default : (T)Marshal.PtrToStructure(handle, typeof(T));
/// <inheritdoc/>
protected override bool InternalReleaseHandle() => NetApiBufferFree(handle) == 0;
}
/// <summary>A custom marshaler for functions using LSA_UNICODE_STRING so that managed strings can be used.</summary>
/// <seealso cref="ICustomMarshaler"/>
internal class NetApiBufferUnicodeStringMarshaler : ICustomMarshaler
{
public static ICustomMarshaler GetInstance(string cookie) => new NetApiBufferUnicodeStringMarshaler();
public void CleanUpManagedData(object ManagedObj)
{
}
public void CleanUpNativeData(IntPtr pNativeData)
{
}
public int GetNativeDataSize() => 0;
public IntPtr MarshalManagedToNative(object ManagedObj) => throw new NotImplementedException();
public object MarshalNativeToManaged(IntPtr pNativeData)
{
if (pNativeData == IntPtr.Zero) return null;
var s = StringHelper.GetString(pNativeData, CharSet.Unicode);
NetApiBufferFree(pNativeData);
return s;
}
}
}
}

3063
PInvoke/NetApi32/LmJoin.cs Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,230 @@
using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class NetApi32
{
/// <summary>
/// A set of bit flags indicating the features of interest in <c>OptionsWanted</c> or features supported <c>OptionsSupported</c> in <see cref="NetRemoteComputerSupports"/>.
/// </summary>
[PInvokeData("lmremutl.h", MSDNShortId = "e807489a-250e-4d4c-adb6-eff8ac30603b")]
[Flags]
public enum RemoteSupportFlags : uint
{
/// <summary>Requests Remote Administration Protocol support.</summary>
SUPPORTS_REMOTE_ADMIN_PROTOCOL = 0x00000002,
/// <summary>Requests RPC support.</summary>
SUPPORTS_RPC = 0x00000004,
/// <summary>Requests Security Account Manager (SAM) support.</summary>
SUPPORTS_SAM_PROTOCOL = 0x00000008,
/// <summary>Requests Unicode standard support.</summary>
SUPPORTS_UNICODE = 0x00000010,
/// <summary>
/// Requests support for the first three values listed in this table. If UNICODE is defined by the calling application, requests
/// the four features listed previously.
/// </summary>
SUPPORTS_LOCAL = 0x00000020,
/// <summary>Requests all supported options.</summary>
SUPPORTS_ANY = 0xFFFFFFFF,
}
/// <summary>
/// The <c>NetRemoteComputerSupports</c> function queries the redirector to retrieve the optional features the remote system
/// supports. Features include Unicode, Remote Procedure Call (RPC), and Remote Administration Protocol support. The function
/// establishes a network connection if one does not exist.
/// </summary>
/// <param name="UncServerName">
/// Pointer to a constant string that specifies the name of the remote server to query. If this parameter is <c>NULL</c>, the local
/// computer is used.
/// </param>
/// <param name="OptionsWanted">
/// <para>
/// Specifies a value that contains a set of bit flags indicating the features of interest. This parameter must be at least one of
/// the following values.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>SUPPORTS_REMOTE_ADMIN_PROTOCOL</term>
/// <term>Requests Remote Administration Protocol support.</term>
/// </item>
/// <item>
/// <term>SUPPORTS_RPC</term>
/// <term>Requests RPC support.</term>
/// </item>
/// <item>
/// <term>SUPPORTS_SAM_PROTOCOL</term>
/// <term>Requests Security Account Manager (SAM) support.</term>
/// </item>
/// <item>
/// <term>SUPPORTS_UNICODE</term>
/// <term>Requests Unicode standard support.</term>
/// </item>
/// <item>
/// <term>SUPPORTS_LOCAL</term>
/// <term>
/// Requests support for the first three values listed in this table. If UNICODE is defined by the calling application, requests the
/// four features listed previously.
/// </term>
/// </item>
/// </list>
/// </param>
/// <param name="OptionsSupported">
/// <para>
/// Pointer to a value that receives a set of bit flags. The flags indicate which features specified by the OptionsWanted parameter
/// are implemented on the computer specified by the UncServerName parameter. (All other bits are set to zero.)
/// </para>
/// <para>The value of this parameter is valid only when the <c>NetRemoteComputerSupports</c> function returns NERR_Success.</para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is NERR_Success.</para>
/// <para>If the function fails, the return value can be one of the following error codes.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>ERROR_INVALID_PARAMETER</term>
/// <term>Either the OptionsWanted parameter or the OptionsSupported parameter is NULL; both parameters are required.</term>
/// </item>
/// <item>
/// <term>ERROR_NOT_ENOUGH_MEMORY</term>
/// <term>Insufficient memory is available.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>No special group membership is required to successfully execute the <c>NetRemoteComputerSupports</c> function.</remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmremutl/nf-lmremutl-netremotecomputersupports NET_API_STATUS
// NET_API_FUNCTION NetRemoteComputerSupports( IN LPCWSTR UncServerName, IN DWORD OptionsWanted, OUT LPDWORD OptionsSupported );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("lmremutl.h", MSDNShortId = "e807489a-250e-4d4c-adb6-eff8ac30603b")]
public static extern Win32Error NetRemoteComputerSupports([MarshalAs(UnmanagedType.LPWStr), Optional] string UncServerName, RemoteSupportFlags OptionsWanted, out RemoteSupportFlags OptionsSupported);
/// <summary>The <c>NetRemoteTOD</c> function returns the time of day information from a specified server.</summary>
/// <param name="UncServerName">
/// Pointer to a constant string that specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If
/// this parameter is <c>NULL</c>, the local computer is used.
/// </param>
/// <param name="BufferPtr">
/// Pointer to the address that receives the TIME_OF_DAY_INFO information structure. This buffer is allocated by the system and must
/// be freed using the NetApiBufferFree function.
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is NERR_Success.</para>
/// <para>If the function fails, the return value is a system error code. For a list of error codes, see System Error Codes.</para>
/// </returns>
/// <remarks>
/// <para>No special group membership is required to successfully execute the <c>NetRemoteTOD</c> function.</para>
/// <para>Examples</para>
/// <para>
/// The following code sample demonstrates how to retrieve and print the current date and time with a call to the <c>NetRemoteTOD</c>
/// function. To do this, the sample uses the TIME_OF_DAY_INFO structure. Finally, the sample frees the memory allocated for the
/// information buffer.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmremutl/nf-lmremutl-netremotetod NET_API_STATUS NET_API_FUNCTION
// NetRemoteTOD( LPCWSTR UncServerName, LPBYTE *BufferPtr );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("lmremutl.h", MSDNShortId = "5a935e09-f188-4ee1-b998-c67488475baa")]
public static extern Win32Error NetRemoteTOD([MarshalAs(UnmanagedType.LPWStr), Optional] string UncServerName, out SafeNetApiBuffer BufferPtr);
/// <summary>The <c>TIME_OF_DAY_INFO</c> structure contains information about the time of day from a remote server.</summary>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmremutl/ns-lmremutl-_time_of_day_info typedef struct _TIME_OF_DAY_INFO {
// DWORD tod_elapsedt; DWORD tod_msecs; DWORD tod_hours; DWORD tod_mins; DWORD tod_secs; DWORD tod_hunds; LONG tod_timezone; DWORD
// tod_tinterval; DWORD tod_day; DWORD tod_month; DWORD tod_year; DWORD tod_weekday; } TIME_OF_DAY_INFO, *PTIME_OF_DAY_INFO, *LPTIME_OF_DAY_INFO;
[PInvokeData("lmremutl.h", MSDNShortId = "bf89f071-5c04-40c2-a7b7-4e59fc9eaa02")]
[StructLayout(LayoutKind.Sequential)]
public struct TIME_OF_DAY_INFO
{
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>The number of seconds since 00:00:00, January 1, 1970, GMT.</para>
/// </summary>
public uint tod_elapsedt;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>The number of milliseconds from an arbitrary starting point (system reset).</para>
/// <para>
/// Typically, this member is read twice, once when the process begins and again at the end. To determine the elapsed time
/// between the process's start and finish, you can subtract the first value from the second.
/// </para>
/// </summary>
public uint tod_msecs;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>The current hour. Valid values are 0 through 23.</para>
/// </summary>
public uint tod_hours;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>The current minute. Valid values are 0 through 59.</para>
/// </summary>
public uint tod_mins;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>The current second. Valid values are 0 through 59.</para>
/// </summary>
public uint tod_secs;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>The current hundredth second (0.01 second). Valid values are 0 through 99.</para>
/// </summary>
public uint tod_hunds;
/// <summary>
/// <para>Type: <c>LONG</c></para>
/// <para>
/// The time zone of the server. This value is calculated, in minutes, from Greenwich Mean Time (GMT). For time zones west of
/// Greenwich, the value is positive; for time zones east of Greenwich, the value is negative. A value of 1 indicates that the
/// time zone is undefined.
/// </para>
/// </summary>
public int tod_timezone;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>The time interval for each tick of the clock. Each integral integer represents one ten-thousandth second (0.0001 second).</para>
/// </summary>
public uint tod_tinterval;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>The day of the month. Valid values are 1 through 31.</para>
/// </summary>
public uint tod_day;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>The month of the year. Valid values are 1 through 12.</para>
/// </summary>
public uint tod_month;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>The year.</para>
/// </summary>
public uint tod_year;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>The day of the week. Valid values are 0 through 6, where 0 is Sunday, 1 is Monday, and so on.</para>
/// </summary>
public uint tod_weekday;
}
}
}

View File

@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Security;
using Vanara.Extensions;
namespace Vanara.PInvoke
{
@ -14,13 +11,11 @@ namespace Vanara.PInvoke
/// PreferedMaximumLength parameter. When specified as an input parameter, this value indicates that the method MUST allocate as much
/// space as the data requires.
/// </summary>
public const int MAX_PREFERRED_LENGTH = -1;
public const uint MAX_PREFERRED_LENGTH = unchecked((uint)-1);
/// <summary>
/// Filters used by <see cref="NetServerEnum(string, int, out SafeNetApiBuffer, int, out int, out int, NetServerEnumFilter, string, IntPtr)"/>.
/// </summary>
/// <summary>Filters used by <see cref="NetServerEnum(string, int, out SafeNetApiBuffer, int, out int, out int, NetServerEnumFilter, string, IntPtr)"/>.</summary>
[Flags]
[PInvokeData("lm.h", MSDNShortId = "aa370623")]
[PInvokeData("lmserver.h", MSDNShortId = "aa370623")]
public enum NetServerEnumFilter : uint
{
/// <summary>All workstations.</summary>
@ -126,6 +121,8 @@ namespace Vanara.PInvoke
SV_TYPE_ALL = 0xFFFFFFFF,
}
[Flags]
[PInvokeData("lmserver.h")]
public enum SERVER_TRANSPORT_FLAGS : uint
{
/// <summary>
@ -158,7 +155,7 @@ namespace Vanara.PInvoke
}
/// <summary>The information level to use for platform-specific information.</summary>
[PInvokeData("lm.h", MSDNShortId = "aa370903")]
[PInvokeData("lmserver.h", MSDNShortId = "aa370903")]
public enum ServerPlatform
{
/// <summary>The MS-DOS platform.</summary>
@ -177,20 +174,8 @@ namespace Vanara.PInvoke
PLATFORM_ID_VMS = 700
}
/// <summary>
/// The NetApiBufferFree function frees the memory that the NetApiBufferAllocate function allocates. Applications should also call
/// NetApiBufferFree to free the memory that other network management functions use internally to return information.
/// </summary>
/// <param name="pBuf">
/// A pointer to a buffer returned previously by another network management function or memory allocated by calling the
/// NetApiBufferAllocate function.
/// </param>
/// <returns>
/// If the function succeeds, the return value is NERR_Success. If the function fails, the return value is a system error code.
/// </returns>
[DllImport(Lib.NetApi32, ExactSpelling = true), SuppressUnmanagedCodeSecurity]
[PInvokeData("lm.h", MSDNShortId = "aa370304")]
public static extern Win32Error NetApiBufferFree(IntPtr pBuf);
/// <summary>Inherit from this interface for any implementation of the SERVER_INFO_XXXX structures to use the helper functions.</summary>
public interface INetServerInfo { }
/// <summary>
/// <para>
@ -338,26 +323,18 @@ namespace Vanara.PInvoke
public static extern Win32Error NetServerComputerNameDel([Optional] string ServerName, string EmulatedServerName);
/// <summary>
/// <para>
/// The <c>NetServerDiskEnum</c> function retrieves a list of disk drives on a server. The function returns an array of
/// three-character strings (a drive letter, a colon, and a terminating null character).
/// </para>
/// </summary>
/// <param name="servername">
/// <para>
/// A pointer to a string that specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this
/// parameter is <c>NULL</c>, the local computer is used.
/// </para>
/// </param>
/// <param name="level">
/// <para>The level of information required. A value of zero is the only valid level.</para>
/// </param>
/// <param name="level">The level of information required. A value of zero is the only valid level.</param>
/// <param name="bufptr">
/// <para>
/// A pointer to the buffer that receives the data. The data is an array of three-character strings (a drive letter, a colon, and a
/// terminating null character). This buffer is allocated by the system and must be freed using the NetApiBufferFree function. Note
/// that you must free the buffer even if the function fails with ERROR_MORE_DATA.
/// </para>
/// </param>
/// <param name="prefmaxlen">
/// <para>
@ -368,21 +345,15 @@ namespace Vanara.PInvoke
/// </para>
/// <para><c>Note</c> This parameter is currently ignored.</para>
/// </param>
/// <param name="entriesread">
/// <para>A pointer to a value that receives the count of elements actually enumerated.</para>
/// </param>
/// <param name="entriesread">A pointer to a value that receives the count of elements actually enumerated.</param>
/// <param name="totalentries">
/// <para>
/// A pointer to a value that receives the total number of entries that could have been enumerated from the current resume position.
/// Note that applications should consider this value only as a hint.
/// </para>
/// </param>
/// <param name="resume_handle">
/// <para>
/// A pointer to a value that contains a resume handle which is used to continue an existing server disk search. The handle should be
/// zero on the first call and left unchanged for subsequent calls. If the resume_handle parameter is a <c>NULL</c> pointer, then no
/// resume handle is stored.
/// </para>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is NERR_Success.</para>
@ -441,11 +412,27 @@ namespace Vanara.PInvoke
// LPDWORD resume_handle );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("lmserver.h", MSDNShortId = "56c981f4-7a1d-4465-bd7b-5996222c4210")]
public static extern Win32Error NetServerDiskEnum([Optional] string servername, int level, out SafeNetApiBuffer bufptr, int prefmaxlen, out int entriesread, out int totalentries, ref uint resume_handle);
public static extern Win32Error NetServerDiskEnum([Optional] string servername, [Optional] uint level, out SafeNetApiBuffer bufptr, uint prefmaxlen, out uint entriesread, out uint totalentries, ref uint resume_handle);
/// <summary>The NetServerEnum function lists all servers of the specified type that are visible in a domain.</summary>
/// <param name="servernane">Reserved; must be NULL.</param>
/// <param name="level">The information level of the data requested.</param>
/// <summary>The <c>NetServerEnum</c> function lists all servers of the specified type that are visible in a domain.</summary>
/// <param name="servername">Reserved; must be <c>NULL</c>.</param>
/// <param name="level">
/// <para>The information level of the data requested. This parameter can be one of the following values.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>100</term>
/// <term>Return server names and platform information. The bufptr parameter points to an array of SERVER_INFO_100 structures.</term>
/// </item>
/// <item>
/// <term>101</term>
/// <term>Return server names, types, and associated data. The bufptr parameter points to an array of SERVER_INFO_101 structures.</term>
/// </item>
/// </list>
/// </param>
/// <param name="bufptr">
/// A pointer to the buffer that receives the data. The format of this data depends on the value of the level parameter. This buffer
/// is allocated by the system and must be freed using the NetApiBufferFree function. Note that you must free the buffer even if the
@ -462,18 +449,254 @@ namespace Vanara.PInvoke
/// A pointer to a value that receives the total number of visible servers and workstations on the network. Note that applications
/// should consider this value only as a hint.
/// </param>
/// <param name="servertype">A value that filters the server entries to return from the enumeration.</param>
/// <param name="servertype">
/// <para>
/// A value that filters the server entries to return from the enumeration. This parameter can be a combination of the following
/// values defined in the Lmserver.h header file.
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>SV_TYPE_WORKSTATION 0x00000001</term>
/// <term>All workstations.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_SERVER 0x00000002</term>
/// <term>All computers that run the Server service.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_SQLSERVER 0x00000004</term>
/// <term>Any server that runs an instance of Microsoft SQL Server.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_DOMAIN_CTRL 0x00000008</term>
/// <term>A server that is primary domain controller.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_DOMAIN_BAKCTRL 0x00000010</term>
/// <term>Any server that is a backup domain controller.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_TIME_SOURCE 0x00000020</term>
/// <term>Any server that runs the Timesource service.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_AFP 0x00000040</term>
/// <term>Any server that runs the Apple Filing Protocol (AFP) file service.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_NOVELL 0x00000080</term>
/// <term>Any server that is a Novell server.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_DOMAIN_MEMBER 0x00000100</term>
/// <term>Any computer that is LAN Manager 2.x domain member.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_PRINTQ_SERVER 0x00000200</term>
/// <term>Any computer that shares a print queue.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_DIALIN_SERVER 0x00000400</term>
/// <term>Any server that runs a dial-in service.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_XENIX_SERVER 0x00000800</term>
/// <term>Any server that is a Xenix server.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_SERVER_UNIX 0x00000800</term>
/// <term>Any server that is a UNIX server. This is the same as the SV_TYPE_XENIX_SERVER.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_NT 0x00001000</term>
/// <term>A workstation or server.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_WFW 0x00002000</term>
/// <term>Any computer that runs Windows for Workgroups.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_SERVER_MFPN 0x00004000</term>
/// <term>Any server that runs the Microsoft File and Print for NetWare service.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_SERVER_NT 0x00008000</term>
/// <term>Any server that is not a domain controller.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_POTENTIAL_BROWSER 0x00010000</term>
/// <term>Any computer that can run the browser service.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_BACKUP_BROWSER 0x00020000</term>
/// <term>A computer that runs a browser service as backup.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_MASTER_BROWSER 0x00040000</term>
/// <term>A computer that runs the master browser service.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_DOMAIN_MASTER 0x00080000</term>
/// <term>A computer that runs the domain master browser.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_SERVER_OSF 0x00100000</term>
/// <term>A computer that runs OSF/1.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_SERVER_VMS 0x00200000</term>
/// <term>A computer that runs Open Virtual Memory System (VMS).</term>
/// </item>
/// <item>
/// <term>SV_TYPE_WINDOWS 0x00400000</term>
/// <term>A computer that runs Windows.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_DFS 0x00800000</term>
/// <term>A computer that is the root of Distributed File System (DFS) tree.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_CLUSTER_NT 0x01000000</term>
/// <term>Server clusters available in the domain.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_TERMINALSERVER 0x02000000</term>
/// <term>A server running the Terminal Server service.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_CLUSTER_VS_NT 0x04000000</term>
/// <term>Cluster virtual servers available in the domain. Windows 2000: This value is not supported.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_DCE 0x10000000</term>
/// <term>A computer that runs IBM Directory and Security Services (DSS) or equivalent.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_ALTERNATE_XPORT 0x20000000</term>
/// <term>A computer that over an alternate transport.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_LOCAL_LIST_ONLY 0x40000000</term>
/// <term>Any computer maintained in a list by the browser. See the following Remarks section.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_DOMAIN_ENUM 0x80000000</term>
/// <term>The primary domain.</term>
/// </item>
/// <item>
/// <term>SV_TYPE_ALL 0xFFFFFFFF</term>
/// <term>All servers. This is a convenience that will return all possible servers.</term>
/// </item>
/// </list>
/// </param>
/// <param name="domain">
/// <para>
/// A pointer to a constant string that specifies the name of the domain for which a list of servers is to be returned. The domain
/// name must be a NetBIOS domain name (for example, microsoft). The NetServerEnum function does not support DNS-style names (for
/// example, microsoft.com). If this parameter is NULL, the primary domain is implied.
/// name must be a NetBIOS domain name (for example, microsoft). The <c>NetServerEnum</c> function does not support DNS-style names
/// (for example, microsoft.com).
/// </para>
/// <para>If this parameter is <c>NULL</c>, the primary domain is implied.</para>
/// </param>
/// <param name="resume_handle">Reserved; must be set to zero.</param>
/// <returns>If the function succeeds, the return value is NERR_Success.</returns>
[DllImport(Lib.NetApi32, ExactSpelling = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
[PInvokeData("lm.h", MSDNShortId = "aa370623")]
public static extern Win32Error NetServerEnum([Optional] string servernane, int level, out SafeNetApiBuffer bufptr, int prefmaxlen, out int entriesread,
out int totalentries, NetServerEnumFilter servertype, string domain, [Optional] IntPtr resume_handle);
/// <returns>
/// <para>If the function succeeds, the return value is NERR_Success.</para>
/// <para>If the function fails, the return value can be one of the following error codes:</para>
/// <list type="table">
/// <listheader>
/// <term>Return code/value</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>ERROR_ACCESS_DENIED 5</term>
/// <term>Access was denied.</term>
/// </item>
/// <item>
/// <term>ERROR_INVALID_PARAMETER 87</term>
/// <term>The parameter is incorrect.</term>
/// </item>
/// <item>
/// <term>ERROR_MORE_DATA 234</term>
/// <term>More entries are available. Specify a large enough buffer to receive all entries.</term>
/// </item>
/// <item>
/// <term>ERROR_NO_BROWSER_SERVERS_FOUND 6118</term>
/// <term>No browser servers found.</term>
/// </item>
/// <item>
/// <term>ERROR_NOT_SUPPORTED 50</term>
/// <term>The request is not supported.</term>
/// </item>
/// <item>
/// <term>NERR_RemoteErr 2127</term>
/// <term>A remote error occurred with no data returned by the server.</term>
/// </item>
/// <item>
/// <term>NERR_ServerNotStarted 2114</term>
/// <term>The server service is not started.</term>
/// </item>
/// <item>
/// <term>NERR_ServiceNotInstalled 2184</term>
/// <term>The service has not been started.</term>
/// </item>
/// <item>
/// <term>NERR_WkstaNotStarted 2138</term>
/// <term>
/// The Workstation service has not been started. The local workstation service is used to communicate with a downlevel remote server.
/// </term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>
/// The <c>NetServerEnum</c> function is used to list all servers of the specified type that are visible in a domain. For example, an
/// application can call <c>NetServerEnum</c> to list all domain controllers only or all servers that run instances of SQL server only.
/// </para>
/// <para>
/// An application combine the bit masks for various server types in the servertype parameter to list several types. For example, a
/// value of SV_TYPE_WORKSTATION | SVTYPE_SERVER (0x00000003) combines the bit masks for SV_TYPE_WORKSTATION (0x00000001) and
/// SV_TYPE_SERVER (0x00000002).
/// </para>
/// <para>If you require more information for a specific server, call the WNetEnumResource function.</para>
/// <para>No special group membership is required to successfully execute the <c>NetServerEnum</c> function.</para>
/// <para>
/// If you specify the value SV_TYPE_LOCAL_LIST_ONLY, the <c>NetServerEnum</c> function returns the list of servers that the browser
/// maintains internally. This has meaning only on the master browser (or on a computer that has been the master browser in the
/// past). The master browser is the computer that currently has rights to determine which computers can be servers or workstations
/// on the network.
/// </para>
/// <para>
/// If there are no servers found that match the types specified in the servertype parameter, the <c>NetServerEnum</c> function
/// returns the bufptr parameter as <c>NULL</c> and DWORD values pointed to by the entriesread and totalentries parameters are set to zero.
/// </para>
/// <para>
/// The <c>NetServerEnum</c> function depends on the browser service being installed and running. If no browser servers are found,
/// then <c>NetServerEnum</c> fails with ERROR_NO_BROWSER_SERVERS_FOUND.
/// </para>
/// <para>
/// If you are programming for Active Directory, you may be able to call certain Active Directory Service Interface (ADSI) methods to
/// achieve the same function you can achieve by calling the network management server functions. For more information, see IADsComputer.
/// </para>
/// <para>Examples</para>
/// <para>
/// The following code sample demonstrates how to list all servers that are visible in a domain with a call to the
/// <c>NetServerEnum</c> function. The sample calls <c>NetServerEnum</c>, specifying information level 101 ( SERVER_INFO_101). If any
/// servers are found, the sample code loops through the entries and prints the retrieved data. If the server is a domain controller,
/// it identifies the server as either a primary domain controller (PDC) or a backup domain controller (BDC). The sample also prints
/// the total number of entries available and a hint about the number of entries actually enumerated, warning the user if all entries
/// were not enumerated. Finally, the sample frees the memory allocated for the information buffer.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmserver/nf-lmserver-netserverenum NET_API_STATUS NET_API_FUNCTION
// NetServerEnum( IN LMCSTR servername, IN DWORD level, OUT LPBYTE *bufptr, IN DWORD prefmaxlen, OUT LPDWORD entriesread, OUT LPDWORD
// totalentries, IN DWORD servertype, IN LMCSTR domain, IN OUT LPDWORD resume_handle );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("lmserver.h", MSDNShortId = "10012a87-805e-4817-9f09-9e5632b1fa09")]
public static extern Win32Error NetServerEnum([Optional] string servername, uint level, out SafeNetApiBuffer bufptr, uint prefmaxlen, out uint entriesread,
out uint totalentries, NetServerEnumFilter servertype, [Optional] string domain, [Optional] IntPtr resume_handle);
/// <summary>The NetServerGetInfo function retrieves current configuration information for the specified server.</summary>
/// <param name="servername">
@ -487,7 +710,7 @@ namespace Vanara.PInvoke
/// </param>
/// <returns>If the function succeeds, the return value is NERR_Success.</returns>
[DllImport(Lib.NetApi32, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("lm.h", MSDNShortId = "aa370624")]
[PInvokeData("lmserver.h", MSDNShortId = "aa370624")]
public static extern Win32Error NetServerGetInfo([Optional] string servername, int level, out SafeNetApiBuffer bufptr);
/// <summary>
@ -1093,13 +1316,11 @@ namespace Vanara.PInvoke
public static extern Win32Error NetServerTransportDel([Optional] string servername, int level, IntPtr bufptr);
/// <summary>
/// <para>The <c>NetServerTransportEnum</c> function supplies information about transport protocols that are managed by the server.</para>
/// The <c>NetServerTransportEnum</c> function supplies information about transport protocols that are managed by the server.
/// </summary>
/// <param name="servername">
/// <para>
/// Pointer to a string that specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this
/// parameter is <c>NULL</c>, the local computer is used.
/// </para>
/// </param>
/// <param name="level">
/// <para>Specifies the information level of the data. This parameter can be one of the following values.</para>
@ -1125,30 +1346,22 @@ namespace Vanara.PInvoke
/// </list>
/// </param>
/// <param name="bufptr">
/// <para>
/// Pointer to the buffer that receives the data. The format of this data depends on the value of the level parameter. This buffer is
/// allocated by the system and must be freed using the NetApiBufferFree function. Note that you must free the buffer even if the
/// function fails with ERROR_MORE_DATA.
/// </para>
/// </param>
/// <param name="prefmaxlen">
/// <para>
/// Specifies the preferred maximum length of returned data, in bytes. If you specify MAX_PREFERRED_LENGTH, the function allocates
/// the amount of memory required for the data. If you specify another value in this parameter, it can restrict the number of bytes
/// that the function returns. If the buffer size is insufficient to hold all entries, the function returns ERROR_MORE_DATA. For more
/// information, see Network Management Function Buffers and Network Management Function Buffer Lengths.
/// </para>
/// </param>
/// <param name="entriesread">
/// <para>Pointer to a value that receives the count of elements actually enumerated.</para>
/// </param>
/// <param name="entriesread">Pointer to a value that receives the count of elements actually enumerated.</param>
/// <param name="totalentries">
/// <para>
/// Pointer to a value that receives the total number of entries that could have been enumerated from the current resume position.
/// Note that applications should consider this value only as a hint.
/// </para>
/// </param>
/// <param name="resume_handle"/>
/// <param name="resume_handle">The resume handle.</param>
/// <returns>
/// <para>If the function succeeds, the return value is NERR_Success.</para>
/// <para>If the function fails, the return value can be one of the following error codes.</para>
@ -1193,12 +1406,12 @@ namespace Vanara.PInvoke
// totalentries, LPDWORD resume_handle );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("lmserver.h", MSDNShortId = "db42ac44-d70d-4b89-882a-6ac83fd611fd")]
public static extern Win32Error NetServerTransportEnum([Optional] string servername, int level, out SafeNetApiBuffer bufptr, int prefmaxlen, out int entriesread, out int totalentries, ref uint resume_handle);
public static extern Win32Error NetServerTransportEnum([Optional] string servername, int level, out SafeNetApiBuffer bufptr, uint prefmaxlen, out uint entriesread, out uint totalentries, ref uint resume_handle);
/// <summary>The <c>SERVER_INFO_100</c> structure contains information about the specified server, including the name and platform.</summary>
/// <seealso cref="INetServerInfo"/>
[StructLayout(LayoutKind.Sequential)]
[PInvokeData("lm.h", MSDNShortId = "aa370897")]
[PInvokeData("lmserver.h", MSDNShortId = "aa370897")]
public struct SERVER_INFO_100 : INetServerInfo
{
/// <summary>The information level to use for platform-specific information.</summary>
@ -1215,7 +1428,7 @@ namespace Vanara.PInvoke
/// </summary>
/// <seealso cref="INetServerInfo"/>
[StructLayout(LayoutKind.Sequential)]
[PInvokeData("lm.h", MSDNShortId = "aa370903")]
[PInvokeData("lmserver.h", MSDNShortId = "aa370903")]
public struct SERVER_INFO_101 : INetServerInfo
{
/// <summary>The information level to use for platform-specific information.</summary>
@ -1256,7 +1469,7 @@ namespace Vanara.PInvoke
/// </summary>
/// <seealso cref="INetServerInfo"/>
[StructLayout(LayoutKind.Sequential)]
[PInvokeData("lm.h", MSDNShortId = "aa370904")]
[PInvokeData("lmserver.h", MSDNShortId = "aa370904")]
public struct SERVER_INFO_102 : INetServerInfo
{
/// <summary>The information level to use for platform-specific information.</summary>
@ -2316,40 +2529,40 @@ namespace Vanara.PInvoke
public byte[] svti3_password;
}
/// <summary>Provides a <see cref="SafeHandle"/> to a buffer that releases a created handle at disposal using NetApiBufferFree.</summary>
public class SafeNetApiBuffer : SafeHANDLE
{
/// <summary>Initializes a new instance of the <see cref="SafeNetApiBuffer"/> class and assigns an existing handle.</summary>
/// <param name="preexistingHandle">An <see cref="IntPtr"/> object that represents the pre-existing handle to use.</param>
/// <param name="ownsHandle">
/// <see langword="true"/> to reliably release the handle during the finalization phase; otherwise, <see langword="false"/> (not recommended).
/// </param>
public SafeNetApiBuffer(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
/// <summary>Initializes a new instance of the <see cref="SafeNetApiBuffer"/> class.</summary>
private SafeNetApiBuffer() : base() { }
/// <summary>Returns an extracted structure from this buffer.</summary>
/// <typeparam name="T">The structure type to extract.</typeparam>
/// <returns>Extracted structure or default(T) if the buffer is invalid.</returns>
public T ToStructure<T>() where T : struct => IsInvalid ? default : (T)Marshal.PtrToStructure(handle, typeof(T));
/// <inheritdoc/>
public override string ToString() => Extensions.StringHelper.GetString(handle);
/// <summary>Extracts a list of structures.</summary>
/// <typeparam name="T">The type of the structure.</typeparam>
/// <param name="count">The count of structures in the list.</param>
/// <returns>The list of structures.</returns>
public IEnumerable<T> ToIEnum<T>(int count) => handle.ToIEnum<T>(count);
/// <summary>Extracts a list of strings. Used by <see cref="DsAddressToSiteNames"/>.</summary>
/// <param name="count">The number of elements in the list.</param>
/// <returns>The list of strings.</returns>
public IEnumerable<string> ToStringEnum(int count) => handle.ToStringEnum(count);
/// <inheritdoc/>
protected override bool InternalReleaseHandle() => NetApiBufferFree(handle) == 0;
}
/*
SERVER_INFO_1005 structure
SERVER_INFO_1010 structure
SERVER_INFO_1016 structure
SERVER_INFO_1017 structure
SERVER_INFO_1018 structure
SERVER_INFO_1107 structure
SERVER_INFO_1501 structure
SERVER_INFO_1502 structure
SERVER_INFO_1503 structure
SERVER_INFO_1506 structure
SERVER_INFO_1509 structure
SERVER_INFO_1510 structure
SERVER_INFO_1511 structure
SERVER_INFO_1512 structure
SERVER_INFO_1513 structure
SERVER_INFO_1515 structure
SERVER_INFO_1516 structure
SERVER_INFO_1518 structure
SERVER_INFO_1523 structure
SERVER_INFO_1528 structure
SERVER_INFO_1529 structure
SERVER_INFO_1530 structure
SERVER_INFO_1533 structure
SERVER_INFO_1536 structure
SERVER_INFO_1538 structure
SERVER_INFO_1539 structure
SERVER_INFO_1540 structure
SERVER_INFO_1541 structure
SERVER_INFO_1542 structure
SERVER_INFO_1544 structure
SERVER_INFO_1550 structure
SERVER_INFO_1552 structure
SERVER_INFO_502 structure
SERVER_INFO_503 structure*/
}
}

View File

@ -10,6 +10,7 @@ namespace Vanara.PInvoke
{
/// <summary>Flags used by SESSION_INFO_XX structures</summary>
[PInvokeData("lmshare.h", MSDNShortId = "a86a00ae-f60a-4b12-a9ac-4b96f9abd6a2")]
[Flags]
public enum SESS
{
/// <summary>The user specified by the sesi502_username member established the session using a guest account.</summary>
@ -20,6 +21,7 @@ namespace Vanara.PInvoke
}
[PInvokeData("lmshare.h", MSDNShortId = "9fb3e0ae-76b5-4432-80dd-f3361738aa7c")]
[Flags]
public enum SHI1005_FLAGS
{
/// <summary>The specified share is present in a Dfs tree structure. This flag cannot be set with NetShareSetInfo.</summary>
@ -140,64 +142,50 @@ namespace Vanara.PInvoke
/// is more than one user using this connection, then it is possible to get more than one structure for the same connection, but with
/// a different user name.
/// </summary>
/// <param name="servername">
/// <para>
/// <param name="servername"><para>
/// Pointer to a string that specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this
/// parameter is <c>NULL</c>, the local computer is used.
/// </para>
/// <para>This string is Unicode if <c>_WIN32_WINNT</c> or <c>FORCE_UNICODE</c> is defined.</para>
/// </param>
/// <param name="qualifier">
/// <para>
/// <para>This string is Unicode if <c>_WIN32_WINNT</c> or <c>FORCE_UNICODE</c> is defined.</para></param>
/// <param name="qualifier"><para>
/// Pointer to a string that specifies a share name or computer name for the connections of interest. If it is a share name, then all
/// the connections made to that share name are listed. If it is a computer name (for example, it starts with two backslash
/// characters), then <c>NetConnectionEnum</c> lists all connections made from that computer to the server specified.
/// </para>
/// <para>This string is Unicode if <c>_WIN32_WINNT</c> or <c>FORCE_UNICODE</c> is defined.</para>
/// </param>
/// <param name="level">
/// <para>Specifies the information level of the data. This parameter can be one of the following values.</para>
/// <para>This string is Unicode if <c>_WIN32_WINNT</c> or <c>FORCE_UNICODE</c> is defined.</para></param>
/// <param name="level"><para>Specifies the information level of the data. This parameter can be one of the following values.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>0</term>
/// <term>Return connection identifiers. The bufptr parameter is a pointer to an array of CONNECTION_INFO_0 structures.</term>
/// </item>
/// <item>
/// <term>1</term>
/// <term>
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>0</term>
/// <term>Return connection identifiers. The bufptr parameter is a pointer to an array of CONNECTION_INFO_0 structures.</term>
/// </item>
/// <item>
/// <term>1</term>
/// <term>
/// Return connection identifiers and connection information. The bufptr parameter is a pointer to an array of CONNECTION_INFO_1 structures.
/// </term>
/// </item>
/// </list>
/// </param>
/// <param name="bufptr">
/// <para>
/// </item>
/// </list></param>
/// <param name="bufptr"><para>
/// Pointer to the address of the buffer that receives the information. The format of this data depends on the value of the level parameter.
/// </para>
/// <para>
/// This buffer is allocated by the system and must be freed using the NetApiBufferFree function. Note that you must free the buffer
/// even if the function fails with <c>ERROR_MORE_DATA</c>.
/// </para>
/// </param>
/// <param name="prefmaxlen">
/// Specifies the preferred maximum length of returned data, in bytes. If you specify <c>MAX_PREFERRED_LENGTH</c>, the function
/// </para></param>
/// <param name="prefmaxlen">Specifies the preferred maximum length of returned data, in bytes. If you specify <c>MAX_PREFERRED_LENGTH</c>, the function
/// allocates the amount of memory required for the data. If you specify another value in this parameter, it can restrict the number
/// of bytes that the function returns. If the buffer size is insufficient to hold all entries, the function returns
/// <c>ERROR_MORE_DATA</c>. For more information, see Network Management Function Buffers and Network Management Function Buffer Lengths.
/// </param>
/// <c>ERROR_MORE_DATA</c>. For more information, see Network Management Function Buffers and Network Management Function Buffer Lengths.</param>
/// <param name="entriesread">Pointer to a value that receives the count of elements actually enumerated.</param>
/// <param name="totalentries">
/// Pointer to a value that receives the total number of entries that could have been enumerated from the current resume position.
/// Note that applications should consider this value only as a hint.
/// </param>
/// <param name="resume_handle">
/// Pointer to a value that contains a resume handle which is used to continue an existing connection search. The handle should be
/// zero on the first call and left unchanged for subsequent calls. If this parameter is <c>NULL</c>, then no resume handle is stored.
/// </param>
/// <param name="totalentries">Pointer to a value that receives the total number of entries that could have been enumerated from the current resume position.
/// Note that applications should consider this value only as a hint.</param>
/// <param name="resume_handle">Pointer to a value that contains a resume handle which is used to continue an existing connection search. The handle should be
/// zero on the first call and left unchanged for subsequent calls. If this parameter is <c>NULL</c>, then no resume handle is stored.</param>
/// <returns>
/// <para>If the function succeeds, the return value is <c>NERR_Success</c>.</para>
/// <para>If the function fails, the return value is a system error code. For a list of error codes, see System Error Codes.</para>
@ -221,7 +209,7 @@ namespace Vanara.PInvoke
// totalentries, LPDWORD resume_handle );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("lmshare.h", MSDNShortId = "935ac6e9-78e0-42ae-a454-0a14b03ddc21")]
public static extern Win32Error NetConnectionEnum(string servername, string qualifier, uint level, out SafeNetApiBuffer bufptr,
public static extern Win32Error NetConnectionEnum([Optional] string servername, string qualifier, uint level, out SafeNetApiBuffer bufptr,
uint prefmaxlen, out uint entriesread, out uint totalentries, ref uint resume_handle);
/// <summary>
@ -380,7 +368,7 @@ namespace Vanara.PInvoke
// totalentries, PDWORD_PTR resume_handle );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("lmshare.h", MSDNShortId = "1375b337-efb0-4be1-94f7-473456a825b5")]
public static extern Win32Error NetFileEnum(string servername, string basepath, string username, uint level, out SafeNetApiBuffer bufptr,
public static extern Win32Error NetFileEnum([Optional] string servername, [Optional] string basepath, [Optional] string username, uint level, out SafeNetApiBuffer bufptr,
uint prefmaxlen, out uint entriesread, out uint totalentries, ref IntPtr resume_handle);
/// <summary>Retrieves information about a particular opening of a server resource.</summary>
@ -667,7 +655,7 @@ namespace Vanara.PInvoke
// entriesread, LPDWORD totalentries, LPDWORD resume_handle );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("lmshare.h", MSDNShortId = "5923a8cc-bf7a-4ffa-b089-fd7f26ee42d2")]
public static extern Win32Error NetSessionEnum(string servername, string UncClientName, string username, uint level, out SafeNetApiBuffer bufptr,
public static extern Win32Error NetSessionEnum([Optional] string servername, string UncClientName, [Optional] string username, uint level, out SafeNetApiBuffer bufptr,
uint prefmaxlen, out uint entriesread, out uint totalentries, ref uint resume_handle);
/// <summary>Retrieves information about a session established between a particular server and workstation.</summary>
@ -786,7 +774,7 @@ namespace Vanara.PInvoke
// NetSessionGetInfo( LMSTR servername, LMSTR UncClientName, LMSTR username, DWORD level, LPBYTE *bufptr );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("lmshare.h", MSDNShortId = "d44fb8d8-2b64-4268-8603-7784e2c5f2d5")]
public static extern Win32Error NetSessionGetInfo(string servername, string UncClientName, string username, uint level, out SafeNetApiBuffer bufptr);
public static extern Win32Error NetSessionGetInfo([Optional] string servername, string UncClientName, string username, uint level, out SafeNetApiBuffer bufptr);
/// <summary>Shares a server resource.</summary>
/// <param name="servername">
@ -900,7 +888,7 @@ namespace Vanara.PInvoke
// LMSTR servername, DWORD level, LPBYTE buf, LPDWORD parm_err );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("lmshare.h", MSDNShortId = "8b51c155-24e8-4d39-b818-eb2d1bb0ee8b")]
public static extern Win32Error NetShareAdd(string servername, uint level, IntPtr buf, out uint parm_err);
public static extern Win32Error NetShareAdd([Optional] string servername, uint level, IntPtr buf, out uint parm_err);
/// <summary>Checks whether or not a server is sharing a device.</summary>
/// <param name="servername">
@ -994,7 +982,7 @@ namespace Vanara.PInvoke
// NetShareCheck( LMSTR servername, LMSTR device, LPDWORD type );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("lmshare.h", MSDNShortId = "8453dcd2-5c58-4fe4-9426-0fd51647394d")]
public static extern Win32Error NetShareCheck(string servername, string device, out STYPE type);
public static extern Win32Error NetShareCheck([Optional] string servername, string device, out STYPE type);
/// <summary>
/// <para>Deletes a share name from a server's list of shared resources, disconnecting all connections to the shared resource.</para>
@ -1061,7 +1049,7 @@ namespace Vanara.PInvoke
// LMSTR servername, LMSTR netname, DWORD reserved );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("lmshare.h", MSDNShortId = "374b8f81-b3d6-4967-bd4a-ffd3fdc3cf7c")]
public static extern Win32Error NetShareDel(string servername, string netname, uint reserved = 0);
public static extern Win32Error NetShareDel([Optional] string servername, string netname, uint reserved = 0);
/// <summary>
/// Deletes a share name from a server's list of shared resources, which disconnects all connections to that share. This function,
@ -1143,7 +1131,7 @@ namespace Vanara.PInvoke
// NetShareDelEx( LMSTR servername, DWORD level, LPBYTE buf );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("lmshare.h", MSDNShortId = "2461c533-351b-48f4-b660-cb17ac3398fa")]
public static extern Win32Error NetShareDelEx(string servername, uint level, IntPtr buf);
public static extern Win32Error NetShareDelEx([Optional] string servername, uint level, IntPtr buf);
/// <summary>
/// <para>Retrieves information about each shared resource on a server.</para>
@ -1262,7 +1250,7 @@ namespace Vanara.PInvoke
// LMSTR servername, DWORD level, LPBYTE *bufptr, DWORD prefmaxlen, LPDWORD entriesread, LPDWORD totalentries, LPDWORD resume_handle );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("lmshare.h", MSDNShortId = "9114c54d-3905-4d40-9162-b3ea605f6fcb")]
public static extern Win32Error NetShareEnum(string servername, uint level, out SafeNetApiBuffer bufptr, uint prefmaxlen,
public static extern Win32Error NetShareEnum([Optional] string servername, uint level, out SafeNetApiBuffer bufptr, uint prefmaxlen,
out uint entriesread, out uint totalentries, ref uint resume_handle);
/// <summary>Retrieves information about a particular shared resource on a server.</summary>
@ -1401,7 +1389,7 @@ namespace Vanara.PInvoke
// NetShareGetInfo( LMSTR servername, LMSTR netname, DWORD level, LPBYTE *bufptr );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("lmshare.h", MSDNShortId = "672ea208-4048-4d2f-9606-ee3e2133765b")]
public static extern Win32Error NetShareGetInfo(string servername, string netname, uint level, out SafeNetApiBuffer bufptr);
public static extern Win32Error NetShareGetInfo([Optional] string servername, string netname, uint level, out SafeNetApiBuffer bufptr);
/// <summary>Sets the parameters of a shared resource.</summary>
/// <param name="servername">
@ -1579,7 +1567,7 @@ namespace Vanara.PInvoke
// NetShareSetInfo( LMSTR servername, LMSTR netname, DWORD level, LPBYTE buf, LPDWORD parm_err );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("lmshare.h", MSDNShortId = "216b0b78-87da-4734-ad07-5ad1c9edf494")]
public static extern Win32Error NetShareSetInfo(string servername, string netname, uint level, IntPtr buf, out uint parm_err);
public static extern Win32Error NetShareSetInfo([Optional] string servername, string netname, uint level, IntPtr buf, out uint parm_err);
/// <summary>Contains the identification number of a connection.</summary>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmshare/ns-lmshare-_connection_info_0 typedef struct _CONNECTION_INFO_0 {

815
PInvoke/NetApi32/LmUse.cs Normal file
View File

@ -0,0 +1,815 @@
using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class NetApi32
{
/// <summary>A set of bit flags that describe connection behavior and credential handling.</summary>
[PInvokeData("lmuse.h", MSDNShortId = "3fb3ad35-f9e5-46ba-b930-fc2ccafd8ee9")]
[Flags]
public enum NetUseFlags
{
/// <summary>Do not connect to the server.</summary>
CREATE_NO_CONNECT = 0x1,
/// <summary>Force a connection to the server, bypassing the CSC.</summary>
CREATE_BYPASS_CSC = 0x2,
/// <summary>
/// Create a connection with credentials passed in this netuse if none exist. If connection already exists then update
/// credentials after issuing remote tree connection. This is needed as CSC cannot verify credentials while offline.
/// </summary>
CREATE_CRED_RESET = 0x4,
/// <summary>No explicit credentials are supplied in the call to NetUseAdd.</summary>
USE_DEFAULT_CREDENTIALS = 0x4,
/// <summary>Enforce connection level integrity.</summary>
CREATE_REQUIRE_CONNECTION_INTEGRITY = 0x8,
/// <summary>Enforce connection level privacy.</summary>
CREATE_REQUIRE_CONNECTION_PRIVACY = 0x10,
/// <summary>Persist the mapping in the registry. (Only valid for global mappings.)</summary>
CREATE_PERSIST_MAPPING = 0x20,
/// <summary>Enables write-through semantics on all files opened via this mapping.</summary>
CREATE_WRITE_THROUGH_SEMANTICS = 0x40,
}
/// <summary>The level of force to use in deleting the connection.</summary>
[PInvokeData("lmuse.h", MSDNShortId = "200b0640-71e9-4f60-bf4c-c8df10bfe095")]
public enum NetUseForce
{
/// <summary>Fail the disconnection if open files exist on the connection.</summary>
USE_NOFORCE = 0,
/// <summary>Do not fail the disconnection if open files exist on the connection.</summary>
USE_FORCE = 1,
/// <summary>Close any open files and delete the connection.</summary>
USE_LOTS_OF_FORCE = 2
}
/// <summary>The status of the connection.</summary>
[PInvokeData("lmuse.h", MSDNShortId = "b9f680b8-b56a-42be-9af1-d7b18328ded4")]
public enum NetUseStatus
{
/// <summary>The connection is valid.</summary>
USE_OK = 0,
/// <summary>Paused by local workstation.</summary>
USE_PAUSED = 1,
/// <summary>Disconnected.</summary>
USE_SESSLOST = 2,
/// <summary>An error occurred.</summary>
USE_DISCONN = 2,
/// <summary>A network error occurred.</summary>
USE_NETERR = 3,
/// <summary>The connection is being made.</summary>
USE_CONN = 4,
/// <summary>Reconnecting.</summary>
USE_RECONN = 5,
}
/// <summary>The type of remote resource being accessed.</summary>
[PInvokeData("lmuse.h", MSDNShortId = "b9f680b8-b56a-42be-9af1-d7b18328ded4")]
public enum NetUseType
{
/// <summary>
/// Matches the type of the server's shared resources. Wildcards can be used only with the NetUseAdd function, and only when the
/// ui1_local member is NULL. For more information, see the following Remarks section.
/// </summary>
USE_WILDCARD = -1,
/// <summary>Disk device.</summary>
USE_DISKDEV = 0,
/// <summary>Spooled printer.</summary>
USE_SPOOLDEV = 1,
/// <summary>Undocumented</summary>
USE_CHARDEV = 2,
/// <summary>Interprocess communication (IPC).</summary>
USE_IPC = 3,
}
/// <summary>
/// The <c>NetUseAdd</c> function establishes a connection between the local computer and a remote server. You can specify a local
/// drive letter or a printer device to connect. If you do not specify a local drive letter or printer device, the function
/// authenticates the client with the server for future connections.
/// </summary>
/// <param name="servername">
/// <para>
/// The UNC name of the computer on which to execute this function. If this parameter is <c>NULL</c>, then the local computer is
/// used. If the UncServerName parameter specified is a remote computer, then the remote computer must support remote RPC calls using
/// the legacy Remote Access Protocol mechanism.
/// </para>
/// <para>This string is Unicode if <c>_WIN32_WINNT</c> or <c>FORCE_UNICODE</c> are defined.</para>
/// </param>
/// <param name="LevelFlags">
/// <para>A value that specifies the information level of the data. This parameter can be one of the following values.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>1</term>
/// <term>
/// Specifies information about the connection between a local device and a shared resource. Information includes the connection
/// status and type. The Buf parameter is a pointer to a USE_INFO_1 structure.
/// </term>
/// </item>
/// <item>
/// <term>2</term>
/// <term>
/// Specifies information about the connection between a local device and a shared resource. Information includes the connection
/// status and type, and a user name and domain name. The Buf parameter is a pointer to a USE_INFO_2 structure.
/// </term>
/// </item>
/// </list>
/// </param>
/// <param name="buf">
/// A pointer to the buffer that specifies the data. The format of this data depends on the value of the Level parameter. For more
/// information, see Network Management Function Buffers.
/// </param>
/// <param name="parm_err">
/// A pointer to a value that receives the index of the first member of the information structure in error when the
/// ERROR_INVALID_PARAMETER error is returned. If this parameter is <c>NULL</c>, the index is not returned on error. For more
/// information, see the following Remarks section.
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is NERR_Success.</para>
/// <para>If the function fails, the return value is a system error code. For a list of error codes, see System Error Codes.</para>
/// </returns>
/// <remarks>
/// <para>You can also use the WNetAddConnection2 and WNetAddConnection3 functions to redirect a local device to a network resource.</para>
/// <para>
/// No special group membership is required to call the <c>NetUseAdd</c> function. This function cannot be executed on a remote
/// server except in cases of downlevel compatibility.
/// </para>
/// <para>
/// This function applies only to the Server Message Block (LAN Manager Workstation) client. The <c>NetUseAdd</c> function does not
/// support Distributed File System (DFS) shares. To add a share using a different network provider (WebDAV or a DFS share, for
/// example), use the WNetAddConnection2 or WNetAddConnection3 function.
/// </para>
/// <para>
/// If the <c>NetUseAdd</c> function returns ERROR_INVALID_PARAMETER, you can use the ParmError parameter to indicate the first
/// member of the information structure that is invalid. (The information structure begins with USE_INFO_ and its format is specified
/// by the Level parameter.) The following table lists the values that can be returned in the ParmError parameter and the
/// corresponding structure member that is in error. (The prefix ui*_ indicates that the member can begin with multiple prefixes, for
/// example, ui1_ or ui2_.)
/// </para>
/// <list type="table">
/// <listheader>
/// <term>Constant</term>
/// <term>Value</term>
/// <term>Member</term>
/// </listheader>
/// <item>
/// <term>USE_LOCAL_PARMNUM</term>
/// <term>1</term>
/// <term>ui*_local</term>
/// </item>
/// <item>
/// <term>USE_REMOTE_PARMNUM</term>
/// <term>2</term>
/// <term>ui*_remote</term>
/// </item>
/// <item>
/// <term>USE_PASSWORD_PARMNUM</term>
/// <term>3</term>
/// <term>ui*_password</term>
/// </item>
/// <item>
/// <term>USE_ASGTYPE_PARMNUM</term>
/// <term>4</term>
/// <term>ui*_asg_type</term>
/// </item>
/// <item>
/// <term>USE_USERNAME_PARMNUM</term>
/// <term>5</term>
/// <term>ui*_username</term>
/// </item>
/// <item>
/// <term>USE_DOMAINNAME_PARMNUM</term>
/// <term>6</term>
/// <term>ui*_domainname</term>
/// </item>
/// </list>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmuse/nf-lmuse-netuseadd NET_API_STATUS NET_API_FUNCTION NetUseAdd( LPTSTR
// servername, DWORD LevelFlags, LPBYTE buf, LPDWORD parm_err );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Auto)]
[PInvokeData("lmuse.h", MSDNShortId = "22550c17-003a-4f59-80f0-58fa3e286844")]
public static extern Win32Error NetUseAdd(string servername, uint LevelFlags, IntPtr buf, out uint parm_err);
/// <summary>
/// <para>The <c>NetUseDel</c> function ends a connection to a shared resource.</para>
/// <para>You can also use the WNetCancelConnection2 function to terminate a network connection.</para>
/// </summary>
/// <param name="UncServerName">
/// <para>
/// The UNC name of the computer on which to execute this function. If this is parameter is <c>NULL</c>, then the local computer is used.
/// </para>
/// <para>
/// If the UncServerName parameter specified is a remote computer, then the remote computer must support remote RPC calls using the
/// legacy Remote Access Protocol mechanism.
/// </para>
/// <para>This string is Unicode if <c>_WIN32_WINNT</c> or <c>FORCE_UNICODE</c> are defined.</para>
/// </param>
/// <param name="UseName">
/// <para>A pointer to a string that specifies the path of the connection to delete.</para>
/// <para>This string is Unicode if <c>_WIN32_WINNT</c> or <c>FORCE_UNICODE</c> are defined.</para>
/// </param>
/// <param name="ForceLevelFlags">
/// <para>The level of force to use in deleting the connection.</para>
/// <para>This parameter can be one of the following values defined in the lmuseflg.h header file.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>USE_NOFORCE</term>
/// <term>Fail the disconnection if open files exist on the connection.</term>
/// </item>
/// <item>
/// <term>USE_FORCE</term>
/// <term>Do not fail the disconnection if open files exist on the connection.</term>
/// </item>
/// <item>
/// <term>USE_LOTS_OF_FORCE</term>
/// <term>Close any open files and delete the connection.</term>
/// </item>
/// </list>
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is NERR_Success.</para>
/// <para>If the function fails, the return value is a system error code. For a list of error codes, see System Error Codes.</para>
/// </returns>
/// <remarks>
/// <para>
/// The <c>NetUseDel</c> function applies only to the Server Message Block (LAN Manager Workstation) client. The <c>NetUseDel</c>
/// function does not support Distributed File System (DFS) shares or other network file systems. To terminate a connection to a
/// share using a different network provider (WebDAV or a DFS share, for example), use the WNetCancelConnection2 function.
/// </para>
/// <para>
/// No special group membership is required to call the <c>NetUseDel</c> function. This function cannot be executed on a remote
/// server except in cases of downlevel compatibility.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmuse/nf-lmuse-netusedel NET_API_STATUS NET_API_FUNCTION NetUseDel( LMSTR
// UncServerName, LMSTR UseName, DWORD ForceLevelFlags );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Auto)]
[PInvokeData("lmuse.h", MSDNShortId = "200b0640-71e9-4f60-bf4c-c8df10bfe095")]
public static extern Win32Error NetUseDel([Optional] string UncServerName, string UseName, NetUseForce ForceLevelFlags);
/// <summary>
/// <para>The <c>NetUseEnum</c> function lists all current connections between the local computer and resources on remote servers.</para>
/// <para>You can also use the WNetOpenEnum and the WNetEnumResource functions to enumerate network resources or connections.</para>
/// </summary>
/// <param name="UncServerName">
/// <para>
/// The UNC name of the computer on which to execute this function. If this is parameter is <c>NULL</c>, then the local computer is
/// used. If the UncServerName parameter specified is a remote computer, then the remote computer must support remote RPC calls using
/// the legacy Remote Access Protocol mechanism.
/// </para>
/// <para>This string is Unicode if <c>_WIN32_WINNT</c> or <c>FORCE_UNICODE</c> are defined.</para>
/// </param>
/// <param name="LevelFlags">
/// <para>The information level of the data requested. This parameter can be one of the following values.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>0</term>
/// <term>
/// Specifies a local device name and the share name of a remote resource. The BufPtr parameter points to an array of USE_INFO_0 structures.
/// </term>
/// </item>
/// <item>
/// <term>1</term>
/// <term>
/// Specifies information about the connection between a local device and a shared resource, including connection status and type.
/// The BufPtr parameter points to an array of USE_INFO_1 structures.
/// </term>
/// </item>
/// <item>
/// <term>2</term>
/// <term>
/// Specifies information about the connection between a local device and a shared resource. Information includes the connection
/// status, connection type, user name, and domain name. The BufPtr parameter points to an array of USE_INFO_2 structures.
/// </term>
/// </item>
/// </list>
/// </param>
/// <param name="BufPtr">
/// A pointer to the buffer that receives the information structures. The format of this data depends on the value of the Level
/// parameter. This buffer is allocated by the system and must be freed using the NetApiBufferFree function when the information is
/// no longer needed. Note that you must free the buffer even if the function fails with <c>ERROR_MORE_DATA</c>.
/// </param>
/// <param name="PreferedMaximumSize">
/// The preferred maximum length, in bytes, of the data to return. If <c>MAX_PREFERRED_LENGTH</c> is specified, the function
/// allocates the amount of memory required for the data. If another value is specified in this parameter, it can restrict the number
/// of bytes that the function returns. If the buffer size is insufficient to hold all entries, the function returns
/// <c>ERROR_MORE_DATA</c>. For more information, see Network Management Function Buffers and Network Management Function Buffer Lengths.
/// </param>
/// <param name="EntriesRead">A pointer to a value that receives the count of elements actually enumerated.</param>
/// <param name="TotalEntries">
/// A pointer to a value that receives the total number of entries that could have been enumerated from the current resume position.
/// Note that applications should consider this value only as a hint.
/// </param>
/// <param name="ResumeHandle">
/// A pointer to a value that contains a resume handle which is used to continue the search. The handle should be zero on the first
/// call and left unchanged for subsequent calls. If ResumeHandle is <c>NULL</c>, then no resume handle is stored.
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is NERR_Success.</para>
/// <para>If the function fails, the return value is a system error code. For a list of error codes, see System Error Codes.</para>
/// <list type="table">
/// <listheader>
/// <term>Return code</term>
/// <term>Description</term>
/// </listheader>
/// <item>
/// <term>ERROR_INVALID_PARAMETER</term>
/// <term>
/// An invalid parameter was passed to the function. This error is returned if a NULL pointer is passed in the BufPtr or entriesread parameters.
/// </term>
/// </item>
/// <item>
/// <term>ERROR_MORE_DATA</term>
/// <term>There is more data to return. This error is returned if the buffer size is insufficient to hold all entries.</term>
/// </item>
/// <item>
/// <term>ERROR_NOT_SUPPORTED</term>
/// <term>
/// The request is not supported. This error is returned if the UncServerName parameter was not NULL and the remote server does not
/// support remote RPC calls using the legacy Remote Access Protocol mechanism.
/// </term>
/// </item>
/// <item>
/// <term>Other</term>
/// <term>Use FormatMessage to obtain the message string for the returned error.</term>
/// </item>
/// </list>
/// </returns>
/// <remarks>
/// <para>
/// No special group membership is required to call the <c>NetUseEnum</c> function. This function cannot be executed on a remote
/// server except in cases of downlevel compatibility using the legacy Remote Access Protocol.
/// </para>
/// <para>To retrieve information about one network connection, you can call the NetUseGetInfo function.</para>
/// <para>
/// This function applies only to the Server Message Block (LAN Manager Workstation) client. The <c>NetUseEnum</c> function does not
/// support Distributed File System (DFS) shares. To enumerate shares using a different network provider (WebDAV or a DFS share, for
/// example), use the WNetOpenEnum, WNetEnumResource, and WNetCloseEnum functions.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmuse/nf-lmuse-netuseenum NET_API_STATUS NET_API_FUNCTION NetUseEnum( LMSTR
// UncServerName, DWORD LevelFlags, LPBYTE *BufPtr, DWORD PreferedMaximumSize, LPDWORD EntriesRead, LPDWORD TotalEntries, LPDWORD
// ResumeHandle );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Auto)]
[PInvokeData("lmuse.h", MSDNShortId = "fb527f85-baea-48e8-b837-967870834ec5")]
public static extern Win32Error NetUseEnum([Optional] string UncServerName, uint LevelFlags, out SafeNetApiBuffer BufPtr, uint PreferedMaximumSize, out uint EntriesRead, out uint TotalEntries, ref uint ResumeHandle);
/// <summary>
/// <para>The <c>NetUseGetInfo</c> function retrieves information about a connection to a shared resource.</para>
/// <para>You can also use the WNetGetConnection function to retrieve the name of a network resource associated with a local device.</para>
/// </summary>
/// <param name="UncServerName">
/// <para>
/// The UNC name of computer on which to execute this function. If this is parameter is <c>NULL</c>, then the local computer is used.
/// If the UncServerName parameter specified is a remote computer, then the remote computer must support remote RPC calls using the
/// legacy Remote Access Protocol mechanism.
/// </para>
/// <para>This string is Unicode if <c>_WIN32_WINNT</c> or <c>FORCE_UNICODE</c> are defined.</para>
/// </param>
/// <param name="UseName">
/// <para>A pointer to a string that specifies the name of the connection for which to return information.</para>
/// <para>This string is Unicode if <c>_WIN32_WINNT</c> or <c>FORCE_UNICODE</c> are defined.</para>
/// </param>
/// <param name="LevelFlags">
/// <para>The information level of the data requested. This parameter can be one of the following values.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>0</term>
/// <term>
/// Specifies a local device name and the share name of a remote resource. The BufPtr parameter is a pointer to a USE_INFO_0 structure.
/// </term>
/// </item>
/// <item>
/// <term>1</term>
/// <term>
/// Specifies information about the connection between a local device and a shared resource, including connection status and type.
/// The BufPtr parameter is a pointer to a USE_INFO_1 structure.
/// </term>
/// </item>
/// <item>
/// <term>2</term>
/// <term>
/// Specifies information about the connection between a local device and a shared resource. Information includes the connection
/// status, connection type, user name, and domain name. The BufPtr parameter is a pointer to a USE_INFO_2 structure.
/// </term>
/// </item>
/// </list>
/// </param>
/// <param name="bufptr">
/// A pointer to the buffer that receives the data. The format of this data depends on the value of the Level parameter. This buffer
/// is allocated by the system and must be freed using the NetApiBufferFree function. For more information, see Network Management
/// Function Buffers and Network Management Function Buffer Lengths.
/// </param>
/// <returns>
/// <para>If the function succeeds, the return value is NERR_Success.</para>
/// <para>If the function fails, the return value is a system error code. For a list of error codes, see System Error Codes.</para>
/// </returns>
/// <remarks>
/// <para>
/// No special group membership is required to call the <c>NetUseGetInfo</c> function. This function cannot be executed on a remote
/// server except in cases of downlevel compatibility.
/// </para>
/// <para>
/// To list all current connections between the local computer and resources on remote servers, you can call the NetUseEnum function.
/// </para>
/// <para>
/// This function applies only to the Server Message Block (LAN Manager Workstation) client. The <c>NetUseGetInfo</c> function does
/// not support Distributed File System (DFS) shares. To retrieve information for a share using a different network provider (WebDAV
/// or a DFS share, for example), use the WNetGetConnection function.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmuse/nf-lmuse-netusegetinfo NET_API_STATUS NET_API_FUNCTION NetUseGetInfo(
// LMSTR UncServerName, LMSTR UseName, DWORD LevelFlags, LPBYTE *bufptr );
[DllImport(Lib.NetApi32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Auto)]
[PInvokeData("lmuse.h", MSDNShortId = "257875db-5ed9-4569-8dbb-5dcc7a6af95c")]
public static extern Win32Error NetUseGetInfo([Optional] string UncServerName, string UseName, uint LevelFlags, out SafeNetApiBuffer bufptr);
/// <summary>The <c>USE_INFO_0</c> structure contains the name of a shared resource and the local device redirected to it.</summary>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmuse/ns-lmuse-_use_info_0 typedef struct _USE_INFO_0 { LMSTR ui0_local;
// LMSTR ui0_remote; } USE_INFO_0, *PUSE_INFO_0, *LPUSE_INFO_0;
[PInvokeData("lmuse.h", MSDNShortId = "86db3f19-84c5-4e89-82cb-f01d17dcf4ec")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct USE_INFO_0
{
/// <summary>
/// Pointer to a Unicode string that specifies the local device name (for example, drive E or LPT1) being redirected to the
/// shared resource. The constant DEVLEN specifies the maximum number of characters in the string.
/// </summary>
public string ui0_local;
/// <summary>
/// Pointer to a Unicode string that specifies the share name of the remote resource being accessed. The string is in the form:
/// </summary>
public string ui0_remote;
}
/// <summary>
/// The <c>USE_INFO_1</c> structure contains information about the connection between a local device and a shared resource. The
/// information includes connection status and connection type.
/// </summary>
/// <remarks>
/// Specifying a <c>ui1_local</c> member that is <c>NULL</c> requests authentication with the server without redirecting a drive
/// letter or a device. Future redirections involving the server while the same connection is in effect use the password specified by
/// the <c>ui1_password</c> member in the initial call to the NetUseAdd function.
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmuse/ns-lmuse-use_info_1 typedef struct _USE_INFO_1 { LMSTR ui1_local; LMSTR
// ui1_remote; LMSTR ui1_password; DWORD ui1_status; DWORD ui1_asg_type; DWORD ui1_refcount; DWORD ui1_usecount; } USE_INFO_1,
// *PUSE_INFO_1, *LPUSE_INFO_1;
[PInvokeData("lmuse.h", MSDNShortId = "b9f680b8-b56a-42be-9af1-d7b18328ded4")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct USE_INFO_1
{
/// <summary>
/// <para>Type: <c>LMSTR</c></para>
/// <para>
/// A pointer to a string that contains the local device name (for example, drive E or LPT1) being redirected to the shared
/// resource. The constant DEVLEN specifies the maximum number of characters in the string. This member can be <c>NULL</c>. For
/// more information, see the following Remarks section.
/// </para>
/// <para>This string is Unicode if <c>_WIN32_WINNT</c> or <c>FORCE_UNICODE</c> are defined.</para>
/// </summary>
public string ui1_local;
/// <summary>
/// <para>Type: <c>LMSTR</c></para>
/// <para>A pointer to a string that contains the share name of the remote resource being accessed. The string is in the form:</para>
/// <para>This string is Unicode if <c>_WIN32_WINNT</c> or <c>FORCE_UNICODE</c> are defined.</para>
/// </summary>
public string ui1_remote;
/// <summary>
/// <para>Type: <c>LMSTR</c></para>
/// <para>
/// A pointer to a string that contains the password needed to establish a session between a specific workstation and a server.
/// </para>
/// <para>This string is Unicode if <c>_WIN32_WINNT</c> or <c>FORCE_UNICODE</c> are defined.</para>
/// </summary>
public string ui1_password;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>The status of the connection. This element is not used by the NetUseAdd function. The following values are defined.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>USE_OK</term>
/// <term>The connection is valid.</term>
/// </item>
/// <item>
/// <term>USE_PAUSED</term>
/// <term>Paused by local workstation.</term>
/// </item>
/// <item>
/// <term>USE_SESSLOST</term>
/// <term>Disconnected.</term>
/// </item>
/// <item>
/// <term>USE_DISCONN</term>
/// <term>An error occurred.</term>
/// </item>
/// <item>
/// <term>USE_NETERR</term>
/// <term>A network error occurred.</term>
/// </item>
/// <item>
/// <term>USE_CONN</term>
/// <term>The connection is being made.</term>
/// </item>
/// <item>
/// <term>USE_RECONN</term>
/// <term>Reconnecting.</term>
/// </item>
/// </list>
/// </summary>
public NetUseStatus ui1_status;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>The type of remote resource being accessed. This member can be one of the following values.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>USE_WILDCARD</term>
/// <term>
/// Matches the type of the server's shared resources. Wildcards can be used only with the NetUseAdd function, and only when the
/// ui1_local member is NULL. For more information, see the following Remarks section.
/// </term>
/// </item>
/// <item>
/// <term>USE_DISKDEV</term>
/// <term>Disk device.</term>
/// </item>
/// <item>
/// <term>USE_SPOOLDEV</term>
/// <term>Spooled printer.</term>
/// </item>
/// <item>
/// <term>USE_IPC</term>
/// <term>Interprocess communication (IPC).</term>
/// </item>
/// </list>
/// </summary>
public NetUseType ui1_asg_type;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>
/// The number of files, directories, and other processes that are open on the remote resource. This element is not used by the
/// NetUseAdd function.
/// </para>
/// </summary>
public uint ui1_refcount;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>
/// The number of explicit connections (redirection with a local device name) or implicit UNC connections (redirection without a
/// local device name) that are established with the resource.
/// </para>
/// </summary>
public uint ui1_usecount;
}
/// <summary>
/// The <c>USE_INFO_2</c> structure contains information about a connection between a local computer and a shared resource, including
/// connection type, connection status, user name, and domain name.
/// </summary>
/// <remarks>
/// Specifying a <c>ui2_local</c> member that is <c>NULL</c> requests authentication with the server without redirecting a drive
/// letter or a device. Future redirections involving the server while the same connection is in effect use the authentication
/// information specified in the initial call to the NetUseAdd function. This information includes the combination of the
/// <c>ui2_password</c>, <c>ui2_username</c>, and <c>ui2_domainname</c> members.
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmuse/ns-lmuse-_use_info_2 typedef struct _USE_INFO_2 { LMSTR ui2_local;
// LMSTR ui2_remote; LMSTR ui2_password; DWORD ui2_status; DWORD ui2_asg_type; DWORD ui2_refcount; DWORD ui2_usecount; LMSTR
// ui2_username; LMSTR ui2_domainname; } USE_INFO_2, *PUSE_INFO_2, *LPUSE_INFO_2;
[PInvokeData("lmuse.h", MSDNShortId = "4cc36108-085a-47c4-9dfa-b46f7e208c8b")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct USE_INFO_2
{
/// <summary>
/// <para>Type: <c>LMSTR</c></para>
/// <para>
/// A pointer to a string that contains the local device name (for example, drive E or LPT1) being redirected to the shared
/// resource. The constant DEVLEN specifies the maximum number of characters in the string. This member can be <c>NULL</c>. For
/// more information, see the following Remarks section.
/// </para>
/// <para>This string is Unicode if <c>_WIN32_WINNT</c> or <c>FORCE_UNICODE</c> are defined.</para>
/// </summary>
public string ui2_local;
/// <summary>
/// <para>Type: <c>LMSTR</c></para>
/// <para>A pointer to a string that contains the share name of the remote resource. The string is in the form</para>
/// </summary>
public string ui2_remote;
/// <summary>
/// <para>Type: <c>LMSTR</c></para>
/// <para>A pointer to a string that contains the password needed to establish a session with a specific workstation.</para>
/// <para>This string is Unicode if <c>_WIN32_WINNT</c> or <c>FORCE_UNICODE</c> are defined.</para>
/// </summary>
public string ui2_password;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>The status of the connection. This element is not used by the NetUseAdd function. The following values are defined.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>USE_OK</term>
/// <term>The connection is successful.</term>
/// </item>
/// <item>
/// <term>USE_PAUSED</term>
/// <term>Paused by a local workstation.</term>
/// </item>
/// <item>
/// <term>USE_SESSLOST</term>
/// <term>Disconnected.</term>
/// </item>
/// <item>
/// <term>USE_DISCONN</term>
/// <term>An error occurred.</term>
/// </item>
/// <item>
/// <term>USE_NETERR</term>
/// <term>A network error occurred.</term>
/// </item>
/// <item>
/// <term>USE_CONN</term>
/// <term>The connection is being made.</term>
/// </item>
/// <item>
/// <term>USE_RECONN</term>
/// <term>Reconnecting.</term>
/// </item>
/// </list>
/// </summary>
public NetUseStatus ui2_status;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>The type of remote resource being accessed. This member can be one of the following values.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>USE_WILDCARD</term>
/// <term>
/// Matches the type of the server's shared resources. Wildcards can be used only with the NetUseAdd function, and only when the
/// ui2_local member is a NULL string. For more information, see the following Remarks section.
/// </term>
/// </item>
/// <item>
/// <term>USE_DISKDEV</term>
/// <term>Disk device.</term>
/// </item>
/// <item>
/// <term>USE_SPOOLDEV</term>
/// <term>Spooled printer.</term>
/// </item>
/// <item>
/// <term>USE_IPC</term>
/// <term>Interprocess communication (IPC).</term>
/// </item>
/// </list>
/// </summary>
public NetUseType ui2_asg_type;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>
/// The number of files, directories, and other processes that are open on the remote resource. This element is not used by the
/// <c>NetUseAdd</c> function.
/// </para>
/// </summary>
public uint ui2_refcount;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>
/// The number of explicit connections (redirection with a local device name) or implicit UNC connections (redirection without a
/// local device name) that are established with the resource.
/// </para>
/// </summary>
public uint ui2_usecount;
/// <summary>
/// <para>Type: <c>LPWSTR</c></para>
/// <para>A pointer to a string that contains the name of the user who initiated the connection.</para>
/// <para>This string is Unicode if <c>_WIN32_WINNT</c> or <c>FORCE_UNICODE</c> are defined.</para>
/// </summary>
public string ui2_username;
/// <summary>
/// <para>Type: <c>LMSTR</c></para>
/// <para>A pointer to a string that contains the domain name of the remote resource.</para>
/// <para>This string is Unicode if <c>_WIN32_WINNT</c> or <c>FORCE_UNICODE</c> are defined.</para>
/// </summary>
public string ui2_domainname;
}
/// <summary>
/// The <c>USE_INFO_3</c> structure contains information about a connection between a local computer and a shared resource, including
/// connection type, connection status, user name, domain name, and specific flags that describe connection behavior.
/// </summary>
// https://docs.microsoft.com/en-us/windows/desktop/api/lmuse/ns-lmuse-_use_info_3 typedef struct _USE_INFO_3 { USE_INFO_2 ui3_ui2;
// ULONG ui3_flags; } USE_INFO_3, *PUSE_INFO_3, *LPUSE_INFO_3;
[PInvokeData("lmuse.h", MSDNShortId = "3fb3ad35-f9e5-46ba-b930-fc2ccafd8ee9")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct USE_INFO_3
{
/// <summary>USE_INFO_2 structure that contains</summary>
public USE_INFO_2 ui3_ui2;
/// <summary>A set of bit flags that describe connection behavior and credential handling.</summary>
public NetUseFlags ui3_flags;
}
/// <summary>Undocumented.</summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct USE_INFO_4
{
/// <summary>Undocumented.</summary>
public USE_INFO_3 ui4_ui3;
/// <summary>Undocumented.</summary>
public uint ui4_auth_identity_length;
/// <summary>Undocumented.</summary>
public IntPtr ui4_auth_identity;
}
/// <summary>Undocumented.</summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct USE_INFO_5
{
/// <summary>Undocumented.</summary>
public USE_INFO_3 ui4_ui3;
/// <summary>Undocumented.</summary>
public uint ui4_auth_identity_length;
/// <summary>Undocumented.</summary>
public IntPtr ui4_auth_identity;
/// <summary>Undocumented.</summary>
public uint ui5_security_descriptor_length;
/// <summary>Undocumented.</summary>
public IntPtr ui5_security_descriptor;
/// <summary>Undocumented.</summary>
public uint ui5_use_options_length;
/// <summary>Undocumented.</summary>
public IntPtr ui5_use_options;
}
}
}

1688
PInvoke/NetApi32/LmWkSta.cs Normal file

File diff suppressed because it is too large Load Diff

View File

@ -25,10 +25,10 @@
<PackageReleaseNotes>Currently implements:
Functions
DsAddressToSiteNamesA, DsAddressToSiteNamesExA, DsAddressToSiteNamesExW, DsAddressToSiteNamesW, DsDeregisterDnsHostRecordsA, DsDeregisterDnsHostRecordsW, DsEnumerateDomainTrustsA, DsEnumerateDomainTrustsW, DsGetDcCloseW, DsGetDcNameA, DsGetDcNameW, DsGetDcNextA, DsGetDcNextW, DsGetDcOpenA, DsGetDcOpenW, DsGetDcSiteCoverageA, DsGetDcSiteCoverageW, DsGetForestTrustInformationW, DsGetSiteNameA, DsGetSiteNameW, DsMergeForestTrustInformationW, DsRoleFreeMemory, DsRoleGetPrimaryDomainInformation, DsValidateSubnetNameA, DsValidateSubnetNameW, NetApiBufferFree, NetServerComputerNameAdd, NetServerComputerNameDel, NetServerDiskEnum, NetServerEnum, NetServerGetInfo, NetServerSetInfo, NetServerTransportAdd, NetServerTransportAddEx, NetServerTransportDel, NetServerTransportEnum
DavAddConnection, DavCancelConnectionsToServer, DavDeleteConnection, DavFlushFile, DavGetExtendedError, DavGetHTTPFromUNCPath, DavGetTheLockOwnerOfTheFile, DavGetUNCFromHTTPPath, DavInvalidateCache, DavRegisterAuthCallback, DavUnregisterAuthCallback, DsAddressToSiteNamesA, DsAddressToSiteNamesExA, DsAddressToSiteNamesExW, DsAddressToSiteNamesW, DsDeregisterDnsHostRecordsA, DsDeregisterDnsHostRecordsW, DsEnumerateDomainTrustsA, DsEnumerateDomainTrustsW, DsGetDcCloseW, DsGetDcNameA, DsGetDcNameW, DsGetDcNextA, DsGetDcNextW, DsGetDcOpenA, DsGetDcOpenW, DsGetDcSiteCoverageA, DsGetDcSiteCoverageW, DsGetForestTrustInformationW, DsGetSiteNameA, DsGetSiteNameW, DsMergeForestTrustInformationW, DsRoleFreeMemory, DsRoleGetPrimaryDomainInformation, DsValidateSubnetNameA, DsValidateSubnetNameW, NetAddAlternateComputerName, NetAlertRaise, NetAlertRaiseEx, NetApiBufferAllocate, NetApiBufferFree, NetApiBufferReallocate, NetApiBufferSize, NetConnectionEnum, NetCreateProvisioningPackage, NetEnumerateComputerNames, NetFileClose, NetFileEnum, NetFileGetInfo, NetFreeAadJoinInformation, NetGetAadJoinInformation, NetGetJoinableOUs, NetGetJoinInformation, NetJoinDomain, NetProvisionComputerAccount, NetRemoteComputerSupports, NetRemoteTOD, NetRemoveAlternateComputerName, NetRenameMachineInDomain, NetRequestOfflineDomainJoin, NetRequestProvisioningPackageInstall, NetServerComputerNameAdd, NetServerComputerNameDel, NetServerDiskEnum, NetServerEnum, NetServerGetInfo, NetServerSetInfo, NetServerTransportAdd, NetServerTransportAddEx, NetServerTransportDel, NetServerTransportEnum, NetSessionDel, NetSessionEnum, NetSessionGetInfo, NetSetPrimaryComputerName, NetShareAdd, NetShareCheck, NetShareDel, NetShareDelEx, NetShareEnum, NetShareGetInfo, NetShareSetInfo, NetUnjoinDomain, NetUseAdd, NetUseDel, NetUseEnum, NetUseGetInfo, NetValidateName, NetWkstaGetInfo, NetWkstaSetInfo, NetWkstaTransportAdd, NetWkstaTransportDel, NetWkstaTransportEnum, NetWkstaUserEnum, NetWkstaUserGetInfo, NetWkstaUserSetInfo
Structures
DOMAIN_CONTROLLER_INFO, DS_DOMAIN_TRUSTS, DSROLE_OPERATION_STATE_INFO, DSROLE_PRIMARY_DOMAIN_INFO_BASIC, DSROLE_UPGRADE_STATUS_INFO, SERVER_INFO_100, SERVER_INFO_101, SERVER_INFO_102, SERVER_INFO_402, SERVER_INFO_403, SERVER_TRANSPORT_INFO_0, SERVER_TRANSPORT_INFO_1, SERVER_TRANSPORT_INFO_2, SERVER_TRANSPORT_INFO_3
DAV_CALLBACK_AUTH_BLOB, DAV_CALLBACK_AUTH_UNP, DAV_CALLBACK_CRED, DOMAIN_CONTROLLER_INFO, DS_DOMAIN_TRUSTS, DSROLE_OPERATION_STATE_INFO, DSROLE_PRIMARY_DOMAIN_INFO_BASIC, DSROLE_UPGRADE_STATUS_INFO, ADMIN_OTHER_INFO, ERRLOG_OTHER_INFO, PRINT_OTHER_INFO, STD_ALERT, USER_OTHER_INFO, DSREG_USER_INFO, NETSETUP_PROVISIONING_PARAMS, TIME_OF_DAY_INFO, SERVER_INFO_100, SERVER_INFO_101, SERVER_INFO_102, SERVER_INFO_402, SERVER_INFO_403, SERVER_TRANSPORT_INFO_0, SERVER_TRANSPORT_INFO_1, SERVER_TRANSPORT_INFO_2, SERVER_TRANSPORT_INFO_3, CONNECTION_INFO_0, CONNECTION_INFO_1, FILE_INFO_2, FILE_INFO_3, SESSION_INFO_0, SESSION_INFO_1, SESSION_INFO_10, SESSION_INFO_2, SESSION_INFO_502, SHARE_INFO_0, SHARE_INFO_1, SHARE_INFO_1004, SHARE_INFO_1005, SHARE_INFO_1006, SHARE_INFO_1501, SHARE_INFO_2, SHARE_INFO_502, SHARE_INFO_503, USE_INFO_0, USE_INFO_1, USE_INFO_2, USE_INFO_3, USE_INFO_4, USE_INFO_5, WKSTA_INFO_100, WKSTA_INFO_101, WKSTA_INFO_1010, WKSTA_INFO_1011, WKSTA_INFO_1012, WKSTA_INFO_1013, WKSTA_INFO_1018, WKSTA_INFO_102, WKSTA_INFO_1023, WKSTA_INFO_1027, WKSTA_INFO_1028, WKSTA_INFO_1032, WKSTA_INFO_1033, WKSTA_INFO_1041, WKSTA_INFO_1042, WKSTA_INFO_1043, WKSTA_INFO_1044, WKSTA_INFO_1045, WKSTA_INFO_1046, WKSTA_INFO_1047, WKSTA_INFO_1048, WKSTA_INFO_1049, WKSTA_INFO_1050, WKSTA_INFO_1051, WKSTA_INFO_1052, WKSTA_INFO_1053, WKSTA_INFO_1054, WKSTA_INFO_1055, WKSTA_INFO_1056, WKSTA_INFO_1057, WKSTA_INFO_1058, WKSTA_INFO_1059, WKSTA_INFO_1060, WKSTA_INFO_1061, WKSTA_INFO_1062, WKSTA_INFO_302, WKSTA_INFO_402, WKSTA_INFO_502, WKSTA_TRANSPORT_INFO_0, WKSTA_USER_INFO_0, WKSTA_USER_INFO_1, WKSTA_USER_INFO_1101
</PackageReleaseNotes>
<LangVersion>latest</LangVersion>
@ -47,9 +47,30 @@ DOMAIN_CONTROLLER_INFO, DS_DOMAIN_TRUSTS, DSROLE_OPERATION_STATE_INFO, DSROLE_PR
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
<Reference Include="System" />
<PackageReference Include="System.ValueTuple">
<Version>4.5.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System" />
<PackageReference Include="System.ValueTuple">
<Version>4.5.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.ValueTuple">
<Version>4.5.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<PackageReference Include="System.ValueTuple">
<Version>4.5.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
<PackageReference Include="System.ValueTuple">
<Version>4.5.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Core\Vanara.Core.csproj" />