com.sun.jna.platform.win32

## Interface Netapi32

- All Superinterfaces:
    AltCallingConvention, Library, StdCall, StdCallLibrary

      public interface Netapi32
      extends StdCallLibrary

  Netapi32.dll Interface.
  Author:
    dblock[at]dblock.org

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.sun.jna.win32.StdCallLibrary

      `StdCallLibrary.StdCallCallback`

    - ### Nested classes/interfaces inherited from interface com.sun.jna.Library

      `Library.Handler`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Netapi32` | `INSTANCE`

    - ### Fields inherited from interface com.sun.jna.win32.StdCallLibrary

      `FUNCTION_MAPPER, STDCALL_CONVENTION`

    - ### Fields inherited from interface com.sun.jna.Library

      `OPTION_ALLOW_OBJECTS, OPTION_CALLING_CONVENTION, OPTION_CLASSLOADER, OPTION_FUNCTION_MAPPER, OPTION_INVOCATION_MAPPER, OPTION_OPEN_FLAGS, OPTION_STRING_ENCODING, OPTION_STRUCTURE_ALIGNMENT, OPTION_TYPE_MAPPER`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `DsEnumerateDomainTrusts(java.lang.String serverName, int Flags, PointerByReference Domains, IntByReference DomainCount)` The DsEnumerateDomainTrusts function obtains domain trust data for a specified domain.
    `int` | `DsGetDcName(java.lang.String ComputerName, java.lang.String DomainName, Guid.GUID DomainGuid, java.lang.String SiteName, int Flags, DsGetDC.PDOMAIN_CONTROLLER_INFO DomainControllerInfo)` The DsGetDcName function returns the name of a domain controller in a specified domain.
    `int` | `DsGetForestTrustInformation(java.lang.String serverName, java.lang.String trustedDomainName, int Flags, NTSecApi.PLSA_FOREST_TRUST_INFORMATION ForestTrustInfo)` The DsGetForestTrustInformationW function obtains forest trust data for a specified domain.
    `int` | `NetApiBufferFree(Pointer buffer)` Frees the memory that the NetApiBufferAllocate function allocates.
    `int` | `NetGetDCName(java.lang.String serverName, java.lang.String domainName, PointerByReference bufptr)` Returns the name of the primary domain controller (PDC).
    `int` | `NetGetJoinInformation(java.lang.String lpServer, PointerByReference lpNameBuffer, IntByReference BufferType)` Retrieves join status information for the specified computer.

    `int`

    `NetGroupEnum(java.lang.String servername, int level, PointerByReference bufptr, int prefmaxlen, IntByReference entriesread, IntByReference totalentries, IntByReference resume_handle)`
    The NetGroupEnum function retrieves information about each global group in the security database, which is the security accounts manager (SAM) database or, in the case of domain controllers, the Active Directory.

    `int` | `NetLocalGroupEnum(java.lang.String serverName, int level, PointerByReference bufptr, int prefmaxlen, IntByReference entriesread, IntByReference totalentries, IntByReference resume_handle)` Returns information about each local group account on the specified server.
    `int` | `NetUserAdd(java.lang.String servername, int level, Structure buf, IntByReference parm_err)` The NetUserAdd function adds a user account and assigns a password and privilege level.
    `int` | `NetUserChangePassword(java.lang.String domainname, java.lang.String username, java.lang.String oldpassword, java.lang.String newpassword)` The NetUserChangePassword function changes a user's password for a specified network server or domain.
    `int` | `NetUserDel(java.lang.String servername, java.lang.String username)` The NetUserDel function deletes a user account from a server.
    `int` | `NetUserEnum(java.lang.String servername, int level, int filter, PointerByReference bufptr, int prefmaxlen, IntByReference entriesread, IntByReference totalentries, IntByReference resume_handle)` The NetUserEnum function provides information about all user accounts on a server.
    `int` | `NetUserGetGroups(java.lang.String servername, java.lang.String username, int level, PointerByReference bufptr, int prefmaxlen, IntByReference entriesread, IntByReference totalentries)` The NetUserGetGroups function retrieves a list of global groups to which a specified user belongs.
    `int` | `NetUserGetInfo(java.lang.String servername, java.lang.String username, int level, PointerByReference bufptr)` The NetUserGetInfo function retrieves information about a particular user account on a server.
    `int` | `NetUserGetLocalGroups(java.lang.String servername, java.lang.String username, int level, int flags, PointerByReference bufptr, int prefmaxlen, IntByReference entriesread, IntByReference totalentries)` The NetUserGetLocalGroups function retrieves a list of local groups to which a specified user belongs.

- - ### Field Detail

    - #### INSTANCE

          static final Netapi32 INSTANCE

  - ### Method Detail

    - #### NetGetJoinInformation

          int NetGetJoinInformation(java.lang.String lpServer,
                                  PointerByReference lpNameBuffer,
                                  IntByReference BufferType)

      Retrieves join status information for the specified computer.
      Parameters:
        `lpServer` - Specifies the DNS or NetBIOS name of the computer on which to call the function.
        `lpNameBuffer` - Receives the NetBIOS name of the domain or workgroup to which the computer is joined.
        `BufferType` - Join status of the specified computer.
      Returns:
        If the function succeeds, the return value is NERR_Success. If the function fails, the return value is a system error code.

    - #### NetApiBufferFree

          int NetApiBufferFree(Pointer buffer)

      Frees the memory that the NetApiBufferAllocate function allocates.
      Parameters:
        `buffer` -
      Returns:
        If the function succeeds, the return value is NERR_Success. If the function fails, the return value is a system error code.

    - #### NetLocalGroupEnum

          int NetLocalGroupEnum(java.lang.String serverName,
                              int level,
                              PointerByReference bufptr,
                              int prefmaxlen,
                              IntByReference entriesread,
                              IntByReference totalentries,
                              IntByReference resume_handle)

      Returns information about each local group account on the specified server.
      Parameters:
        `serverName` - Specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is NULL, the local computer is used.
        `level` - Specifies the information level of the data.
        `bufptr` - Pointer to the address of the buffer that receives the information structure.
        `prefmaxlen` - Specifies the preferred maximum length of returned data, in bytes.
        `entriesread` - Pointer to a value that receives the count of elements actually enumerated.
        `totalentries` - Pointer to a value that receives the approximate total number of entries that could have been enumerated from the current resume position.
        `resume_handle` - Pointer to a value that contains a resume handle that is used to continue an existing local group search.
      Returns:
        If the function succeeds, the return value is NERR_Success.

    - #### NetGetDCName

          int NetGetDCName(java.lang.String serverName,
                         java.lang.String domainName,
                         PointerByReference bufptr)

      Returns the name of the primary domain controller (PDC).
      Parameters:
        `serverName` - Specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is NULL, the local computer is used.
        `domainName` - Specifies the name of the domain.
        `bufptr` - Receives a string that specifies the server name of the PDC of the domain.
      Returns:
        If the function succeeds, the return value is NERR_Success.

    - #### NetGroupEnum

          int NetGroupEnum(java.lang.String servername,
                         int level,
                         PointerByReference bufptr,
                         int prefmaxlen,
                         IntByReference entriesread,
                         IntByReference totalentries,
                         IntByReference resume_handle)

      The NetGroupEnum function retrieves information about each global group in the security database, which is the security accounts manager (SAM) database or, in the case of domain controllers, the Active Directory.
      Parameters:
        `servername` - 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 NULL, the local computer is used.
        `level` - Specifies the information level of the data.
        `bufptr` - Pointer to the buffer to receive the global group information structure. The format of this data depends on the value of the level parameter.
        `prefmaxlen` - Specifies the preferred maximum length of the returned data, in bytes. If you specify MAX_PREFERRED_LENGTH, the function allocates the amount of memory required to hold 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.
        `entriesread` - Pointer to a value that receives the count of elements actually enumerated.
        `totalentries` - Pointer to a value that receives the total number of entries that could have been enumerated from the current resume position. The total number of entries is only a hint.
        `resume_handle` - Pointer to a variable that contains a resume handle that is used to continue the global group enumeration. The handle should be zero on the first call and left unchanged for subsequent calls. If resume_handle is NULL, no resume handle is stored.
      Returns:
        If the function succeeds, the return value is NERR_Success.

    - #### NetUserEnum

          int NetUserEnum(java.lang.String servername,
                        int level,
                        int filter,
                        PointerByReference bufptr,
                        int prefmaxlen,
                        IntByReference entriesread,
                        IntByReference totalentries,
                        IntByReference resume_handle)

      The NetUserEnum function provides information about all user accounts on a server.
      Parameters:
        `servername` - 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 NULL, the local computer is used.
        `level` - Specifies the information level of the data.
        `filter` - Specifies a value that filters the account types for enumeration.
        `bufptr` - 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.
        `prefmaxlen` - Specifies the preferred maximum length, in 8-bit bytes of returned data. 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.
        `entriesread` - Pointer to a value that receives the count of elements actually enumerated.
        `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.
        `resume_handle` - Pointer to a value that contains a resume handle which is used to continue an existing user search. The handle should be zero on the first call and left unchanged for subsequent calls. If resume_handle is NULL, then no resume handle is stored.
      Returns:
        If the function succeeds, the return value is NERR_Success.

    - #### NetUserGetGroups

          int NetUserGetGroups(java.lang.String servername,
                             java.lang.String username,
                             int level,
                             PointerByReference bufptr,
                             int prefmaxlen,
                             IntByReference entriesread,
                             IntByReference totalentries)

      The NetUserGetGroups function retrieves a list of global groups to which a specified user belongs.
      Parameters:
        `servername` - 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 NULL, the local computer is used.
        `username` - Pointer to a constant string that specifies the name of the user to search for in each group account. For more information, see the following Remarks section.
        `level` - Specifies the information level of the data.
        `bufptr` - Pointer to the buffer that receives the data. 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.
        `prefmaxlen` - 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.
        `entriesread` - Pointer to a value that receives the count of elements actually retrieved.
        `totalentries` - Pointer to a value that receives the total number of entries that could have been retrieved.
      Returns:
        If the function succeeds, the return value is NERR_Success.

    - #### NetUserGetLocalGroups

          int NetUserGetLocalGroups(java.lang.String servername,
                                  java.lang.String username,
                                  int level,
                                  int flags,
                                  PointerByReference bufptr,
                                  int prefmaxlen,
                                  IntByReference entriesread,
                                  IntByReference totalentries)

      The NetUserGetLocalGroups function retrieves a list of local groups to which a specified user belongs.
      Parameters:
        `servername` - 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 NULL, the local computer is used.
        `username` - Pointer to a constant string that specifies the name of the user for which to return local group membership information. If the string is of the form DomainName\UserName the user name is expected to be found on that domain. If the string is of the form UserName, the user name is expected to be found on the server specified by the servername parameter.
        `level` - Specifies the information level of the data.
        `flags` - Specifies a bitmask of flags. Currently, only the value LG_INCLUDE_INDIRECT is defined. If this bit is set, the function also returns the names of the local groups in which the user is indirectly a member (that is, the user has membership in a global group that is itself a member of one or more local groups).
        `bufptr` - 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.
        `prefmaxlen` - 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.
        `entriesread` - Pointer to a value that receives the count of elements actually enumerated.
        `totalentries` - Pointer to a value that receives the total number of entries that could have been enumerated.
      Returns:
        If the function succeeds, the return value is NERR_Success.

    - #### NetUserAdd

          int NetUserAdd(java.lang.String servername,
                       int level,
                       Structure buf,
                       IntByReference parm_err)

      The NetUserAdd function adds a user account and assigns a password and privilege level.
      Parameters:
        `servername` - Pointer to a constant string that specifies the DNS or NetBIOS name of the remote server on which the function is to execute.
        `level` - Specifies the information level of the data.
        `buf` - Pointer to the buffer that specifies the data. The format of this data depends on the value of the level parameter.
        `parm_err` - Pointer to a value that receives the index of the first member of the user information structure that causes ERROR_INVALID_PARAMETER. If this parameter is NULL, the index is not returned on error.
      Returns:
        If the function succeeds, the return value is NERR_Success.

    - #### NetUserDel

          int NetUserDel(java.lang.String servername,
                       java.lang.String username)

      The NetUserDel function deletes a user account from a server.
      Parameters:
        `servername` - 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 NULL, the local computer is used.
        `username` - Pointer to a constant string that specifies the name of the user account to delete.
      Returns:
        If the function succeeds, the return value is NERR_Success.

    - #### NetUserChangePassword

          int NetUserChangePassword(java.lang.String domainname,
                                  java.lang.String username,
                                  java.lang.String oldpassword,
                                  java.lang.String newpassword)

      The NetUserChangePassword function changes a user's password for a specified network server or domain.
      Parameters:
        `domainname` - Pointer to a constant string that specifies the DNS or NetBIOS name of a remote server or domain on which the function is to execute. If this parameter is NULL, the logon domain of the caller is used.
        `username` - Pointer to a constant string that specifies a user name. The NetUserChangePassword function changes the password for the specified user. If this parameter is NULL, the logon name of the caller is used.
        `oldpassword` - Pointer to a constant string that specifies the user's old password.
        `newpassword` - Pointer to a constant string that specifies the user's new password.
      Returns:
        If the function succeeds, the return value is NERR_Success.

    - #### DsGetDcName

          int DsGetDcName(java.lang.String ComputerName,
                        java.lang.String DomainName,
                        Guid.GUID DomainGuid,
                        java.lang.String SiteName,
                        int Flags,
                        DsGetDC.PDOMAIN_CONTROLLER_INFO DomainControllerInfo)

      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.
      Parameters:
        `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.
        `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.
        `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.
        `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.
        `Flags` - Contains a set of flags that provide additional data used to process the request.
        `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.
      Returns:
        If the function returns domain controller data, the return value is ERROR_SUCCESS. If the function fails, the return code is one of ERROR_* values.

    - #### DsGetForestTrustInformation

          int DsGetForestTrustInformation(java.lang.String serverName,
                                        java.lang.String trustedDomainName,
                                        int Flags,
                                        NTSecApi.PLSA_FOREST_TRUST_INFORMATION ForestTrustInfo)

      The DsGetForestTrustInformationW function obtains forest trust data for a specified domain.
      Parameters:
        `serverName` - Contains the name of the domain controller that DsGetForestTrustInformationW is connected to remotely. The caller must be an authenticated user on this server. If this parameter is NULL, the local server is used.
        `trustedDomainName` - Contains the NETBIOS or DNS name of the trusted domain that the forest trust data is to be retrieved for. This domain must have the TRUST_ATTRIBUTE_FOREST_TRANSITIVE trust attribute. If this parameter is NULL, the forest trust data for the domain hosted by ServerName is retrieved.
        `Flags` - Contains a set of flags that modify the behavior of this function. DS_GFTI_UPDATE_TDO: If this flag is set, DsGetForestTrustInformationW will update the forest trust data of the trusted domain identified by the TrustedDomainName parameter.
        `ForestTrustInfo` - Pointer to an LSA_FOREST_TRUST_INFORMATION structure pointer that receives the forest trust data that describes the namespaces claimed by the domain specified by TrustedDomainName. The Time member of all returned records will be zero.
      Returns:
        Returns NO_ERROR if successful or a Win32 error code otherwise.

    - #### DsEnumerateDomainTrusts

          int DsEnumerateDomainTrusts(java.lang.String serverName,
                                    int Flags,
                                    PointerByReference Domains,
                                    IntByReference DomainCount)

      The DsEnumerateDomainTrusts function obtains domain trust data for a specified domain.
      Parameters:
        `serverName` - Pointer to a null-terminated string that specifies the name of a computer in the domain to obtain the trust information for. This computer must be running the Windows 2000 or later operating system. If this parameter is NULL, the name of the local computer is used. The caller must be an authenticated user in this domain.
        `Flags` - Contains a set of flags that determines which domain trusts to enumerate.
        `Domains` - Receives a pointer which points to 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.
        `DomainCount` - Pointer to a ULONG value that receives the number of elements returned in the Domains array.
      Returns:
        Returns ERROR_SUCCESS if successful or a Win32 error code otherwise.

    - #### NetUserGetInfo

          int NetUserGetInfo(java.lang.String servername,
                           java.lang.String username,
                           int level,
                           PointerByReference bufptr)

      The NetUserGetInfo function retrieves information about a particular user account on a server.
      Parameters:
        `servername` - A 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 NULL, the local computer is used.
        `username` - A pointer to a constant string that specifies the name of the user account for which to return information. For more information, see the following Remarks section.
        `level` - The information level of the data. This parameter can be one of the following values. Value Meaning 0 Return the user account name. The bufptr parameter points to a USER_INFO_0 structure. 1 Return detailed information about the user account. The bufptr parameter points to a USER_INFO_1 structure. 2 Return detailed information and additional attributes about the user account. The bufptr parameter points to a USER_INFO_2 structure. 3 Return detailed information and additional attributes about the user account. This level is valid only on servers. The bufptr parameter points to a USER_INFO_3 structure. Note that it is recommended that you use USER_INFO_4 instead. 4 Return detailed information and additional attributes about the user account. This level is valid only on servers. The bufptr parameter points to a USER_INFO_4 structure. Windows 2000: This level is not supported. 10 Return user and account names and comments. The bufptr parameter points to a USER_INFO_10 structure. 11 Return detailed information about the user account. The bufptr parameter points to a USER_INFO_11 structure. 20 Return the user's name and identifier and various account attributes. The bufptr parameter points to a USER_INFO_20 structure. Note that on Windows XP and later, it is recommended that you use USER_INFO_23 instead. 23 Return the user's name and identifier and various account attributes. The bufptr parameter points to a USER_INFO_23 structure. Windows 2000: This level is not supported.
        `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.
      Returns:
        If the function succeeds, the return value is NERR_Success.

Copyright © 2007-2013 Timothy Wall. All Rights Reserved.