1 /* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved 2 * 3 * The contents of this file is dual-licensed under 2 4 * alternative Open Source/Free licenses: LGPL 2.1 or later and 5 * Apache License 2.0. (starting with JNA version 4.0.0). 6 * 7 * You can freely decide which license you want to apply to 8 * the project. 9 * 10 * You may obtain a copy of the LGPL License at: 11 * 12 * http://www.gnu.org/licenses/licenses.html 13 * 14 * A copy is also included in the downloadable source code package 15 * containing JNA, in file "LGPL2.1". 16 * 17 * You may obtain a copy of the Apache License at: 18 * 19 * http://www.apache.org/licenses/ 20 * 21 * A copy is also included in the downloadable source code package 22 * containing JNA, in file "AL2.0". 23 */ 24 package com.sun.jna.platform.win32; 25 26 import com.sun.jna.Native; 27 import com.sun.jna.Pointer; 28 import com.sun.jna.Structure; 29 import com.sun.jna.Structure.FieldOrder; 30 import com.sun.jna.WString; 31 import com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO; 32 import com.sun.jna.platform.win32.Guid.GUID; 33 import com.sun.jna.platform.win32.NTSecApi.PLSA_FOREST_TRUST_INFORMATION; 34 import com.sun.jna.ptr.IntByReference; 35 import com.sun.jna.ptr.PointerByReference; 36 import com.sun.jna.win32.StdCallLibrary; 37 import com.sun.jna.win32.W32APIOptions; 38 import com.sun.jna.win32.W32APITypeMapper; 39 40 /** 41 * Netapi32.dll Interface. 42 * @author dblock[at]dblock.org 43 */ 44 public interface Netapi32 extends StdCallLibrary { 45 46 Netapi32 INSTANCE = Native.load("Netapi32", Netapi32.class, W32APIOptions.DEFAULT_OPTIONS); 47 48 int MAX_PREFERRED_LENGTH = -1; 49 50 /** 51 * Contains information about the session, including name of the computer; name 52 * of the user; and active and idle times for the session. 53 */ 54 @FieldOrder({ "sesi10_cname", "sesi10_username", "sesi10_time", "sesi10_idle_time" }) 55 class SESSION_INFO_10 extends Structure { 56 public String sesi10_cname; 57 public String sesi10_username; 58 public int sesi10_time; 59 public int sesi10_idle_time; 60 SESSION_INFO_10()61 public SESSION_INFO_10() { 62 super(W32APITypeMapper.UNICODE); 63 } 64 SESSION_INFO_10(Pointer p)65 public SESSION_INFO_10(Pointer p) { 66 super(p, Structure.ALIGN_DEFAULT, W32APITypeMapper.UNICODE); 67 read(); 68 } 69 } 70 71 /** 72 * Provides information about sessions established on a server. 73 * 74 * @param servername 75 * Pointer to a string that specifies the DNS or NetBIOS name of the 76 * remote server on which the function is to execute. If this 77 * parameter is NULL, the local computer is used. 78 * @param UncClientName 79 * Pointer to a string that specifies the name of the computer 80 * session for which information is to be returned. If this parameter 81 * is NULL, NetSessionEnum returns information for all computer 82 * sessions on the server. 83 * @param username 84 * Pointer to a string that specifies the name of the user for which 85 * information is to be returned. If this parameter is NULL, 86 * NetSessionEnum returns information for all users. 87 * @param level 88 * Specifies the information level of the data. This parameter can be 89 * one of 0, 1, 2, 10, 502. 90 * @param bufptr 91 * Pointer to the buffer that receives the data. The format of this 92 * data depends on the value of the level parameter, for example 93 * {@code SESSION_INFO_0} for level 0. 94 * <p> 95 * This buffer is allocated by the system and must be freed using the 96 * {@link #NetApiBufferFree} function. Note that you must free the 97 * buffer even if the function fails with {@code ERROR_MORE_DATA}. 98 * @param prefmaxlen 99 * Specifies the preferred maximum length of returned data, in bytes. 100 * If you specify {@link #MAX_PREFERRED_LENGTH}, the function 101 * allocates the amount of memory required for the data. If you 102 * specify another value in this parameter, it can restrict the 103 * number of bytes that the function returns. If the buffer size is 104 * insufficient to hold all entries, the function returns 105 * {@code ERROR_MORE_DATA}. 106 * @param entriesread 107 * Pointer to a value that receives the count of elements actually 108 * enumerated. 109 * @param totalentries 110 * Pointer to a value that receives the total number of entries that 111 * could have been enumerated from the current resume position. Note 112 * that applications should consider this value only as a hint. 113 * @param resume_handle 114 * Pointer to a value that contains a resume handle which is used to 115 * continue an existing session search. The handle should be zero on 116 * the first call and left unchanged for subsequent calls. If 117 * resume_handle is NULL, no resume handle is stored. 118 * @return If the function succeeds, the return value is NERR_Success (0). If 119 * the function fails, the return value is an error code. 120 */ NetSessionEnum(WString servername, WString UncClientName, WString username, int level, PointerByReference bufptr, int prefmaxlen, IntByReference entriesread, IntByReference totalentries, IntByReference resume_handle)121 int NetSessionEnum(WString servername, WString UncClientName, WString username, int level, 122 PointerByReference bufptr, int prefmaxlen, IntByReference entriesread, IntByReference totalentries, 123 IntByReference resume_handle); 124 125 /** 126 * Retrieves join status information for the specified computer. 127 * 128 * @param lpServer 129 * Specifies the DNS or NetBIOS name of the computer on which to 130 * call the function. 131 * @param lpNameBuffer 132 * Receives the NetBIOS name of the domain or workgroup to which 133 * the computer is joined. 134 * @param BufferType 135 * Join status of the specified computer. 136 * @return If the function succeeds, the return value is NERR_Success. If 137 * the function fails, the return value is a system error code. 138 */ NetGetJoinInformation(String lpServer, PointerByReference lpNameBuffer, IntByReference BufferType)139 public int NetGetJoinInformation(String lpServer, 140 PointerByReference lpNameBuffer, IntByReference BufferType); 141 142 /** 143 * Frees the memory that the NetApiBufferAllocate function allocates. 144 * 145 * @param buffer buffer 146 * @return If the function succeeds, the return value is NERR_Success. If 147 * the function fails, the return value is a system error code. 148 */ NetApiBufferFree(Pointer buffer)149 public int NetApiBufferFree(Pointer buffer); 150 151 /** 152 * Returns information about each local group account on the specified 153 * server. 154 * 155 * @param serverName 156 * Specifies the DNS or NetBIOS name of the remote server on 157 * which the function is to execute. If this parameter is NULL, 158 * the local computer is used. 159 * @param level 160 * Specifies the information level of the data. 161 * @param bufptr 162 * Pointer to the address of the buffer that receives the 163 * information structure. 164 * @param prefmaxlen 165 * Specifies the preferred maximum length of returned data, in 166 * bytes. 167 * @param entriesread 168 * Pointer to a value that receives the count of elements 169 * actually enumerated. 170 * @param totalentries 171 * Pointer to a value that receives the approximate total number 172 * of entries that could have been enumerated from the current 173 * resume position. 174 * @param resume_handle 175 * Pointer to a value that contains a resume handle that is used 176 * to continue an existing local group search. 177 * @return If the function succeeds, the return value is NERR_Success. 178 */ NetLocalGroupEnum(String serverName, int level, PointerByReference bufptr, int prefmaxlen, IntByReference entriesread, IntByReference totalentries, IntByReference resume_handle)179 public int NetLocalGroupEnum(String serverName, int level, 180 PointerByReference bufptr, int prefmaxlen, 181 IntByReference entriesread, IntByReference totalentries, 182 IntByReference resume_handle); 183 184 /** 185 * Returns the name of the primary domain controller (PDC). 186 * 187 * @param serverName 188 * Specifies the DNS or NetBIOS name of the remote server on which the function is 189 * to execute. If this parameter is NULL, the local computer is used. 190 * @param domainName 191 * Specifies the name of the domain. 192 * @param bufptr 193 * Receives a string that specifies the server name of the PDC of the domain. 194 * @return 195 * If the function succeeds, the return value is NERR_Success. 196 */ NetGetDCName(String serverName, String domainName, PointerByReference bufptr)197 public int NetGetDCName(String serverName, String domainName, 198 PointerByReference bufptr); 199 200 /** 201 * The NetGroupEnum function retrieves information about each global group 202 * in the security database, which is the security accounts manager (SAM) database or, 203 * in the case of domain controllers, the Active Directory. 204 * @param servername 205 * Pointer to a constant string that specifies the DNS or NetBIOS name of the 206 * remote server on which the function is to execute. If this parameter is NULL, 207 * the local computer is used. 208 * @param level 209 * Specifies the information level of the data. 210 * @param bufptr 211 * Pointer to the buffer to receive the global group information structure. 212 * The format of this data depends on the value of the level parameter. 213 * @param prefmaxlen 214 * Specifies the preferred maximum length of the returned data, in bytes. 215 * If you specify MAX_PREFERRED_LENGTH, the function allocates the amount of 216 * memory required to hold the data. If you specify another value in this 217 * parameter, it can restrict the number of bytes that the function returns. 218 * If the buffer size is insufficient to hold all entries, the function 219 * returns ERROR_MORE_DATA. 220 * @param entriesread 221 * Pointer to a value that receives the count of elements actually enumerated. 222 * @param totalentries 223 * Pointer to a value that receives the total number of entries that could have 224 * been enumerated from the current resume position. The total number of entries 225 * is only a hint. 226 * @param resume_handle 227 * Pointer to a variable that contains a resume handle that is used to continue 228 * the global group enumeration. The handle should be zero on the first call and 229 * left unchanged for subsequent calls. If resume_handle is NULL, no resume handle 230 * is stored. 231 * @return 232 * If the function succeeds, the return value is NERR_Success. 233 */ NetGroupEnum(String servername, int level, PointerByReference bufptr, int prefmaxlen, IntByReference entriesread, IntByReference totalentries, IntByReference resume_handle)234 public int NetGroupEnum(String servername, int level, PointerByReference bufptr, 235 int prefmaxlen, IntByReference entriesread, IntByReference totalentries, 236 IntByReference resume_handle); 237 238 /** 239 * The NetUserEnum function provides information about all user accounts on a server. 240 * @param servername 241 * Pointer to a constant string that specifies the DNS or NetBIOS name of the 242 * remote server on which the function is to execute. If this parameter is NULL, 243 * the local computer is used. 244 * @param level 245 * Specifies the information level of the data. 246 * @param filter 247 * Specifies a value that filters the account types for enumeration. 248 * @param bufptr 249 * Pointer to the buffer that receives the data. The format of this data depends 250 * on the value of the level parameter. This buffer is allocated by the system and 251 * must be freed using the NetApiBufferFree function. Note that you must free the 252 * buffer even if the function fails with ERROR_MORE_DATA. 253 * @param prefmaxlen 254 * Specifies the preferred maximum length, in 8-bit bytes of returned data. If you 255 * specify MAX_PREFERRED_LENGTH, the function allocates the amount of memory 256 * required for the data. If you specify another value in this parameter, it can 257 * restrict the number of bytes that the function returns. If the buffer size is 258 * insufficient to hold all entries, the function returns ERROR_MORE_DATA. 259 * @param entriesread 260 * Pointer to a value that receives the count of elements actually enumerated. 261 * @param totalentries 262 * Pointer to a value that receives the total number of entries that could have 263 * been enumerated from the current resume position. Note that applications should 264 * consider this value only as a hint. 265 * @param resume_handle 266 * Pointer to a value that contains a resume handle which is used to continue an 267 * existing user search. The handle should be zero on the first call and left 268 * unchanged for subsequent calls. If resume_handle is NULL, then no resume 269 * handle is stored. 270 * @return 271 * If the function succeeds, the return value is NERR_Success. 272 */ NetUserEnum(String servername, int level, int filter, PointerByReference bufptr, int prefmaxlen, IntByReference entriesread, IntByReference totalentries, IntByReference resume_handle)273 public int NetUserEnum(String servername, int level, int filter, PointerByReference bufptr, 274 int prefmaxlen, IntByReference entriesread, IntByReference totalentries, 275 IntByReference resume_handle); 276 277 /** 278 * The NetUserGetGroups function retrieves a list of global groups to which a 279 * specified user belongs. 280 * @param servername 281 * Pointer to a constant string that specifies the DNS or NetBIOS name of the 282 * remote server on which the function is to execute. If this parameter is NULL, 283 * the local computer is used. 284 * @param username 285 * Pointer to a constant string that specifies the name of the user to search for 286 * in each group account. For more information, see the following Remarks section. 287 * @param level 288 * Specifies the information level of the data. 289 * @param bufptr 290 * Pointer to the buffer that receives the data. This buffer is allocated by the 291 * system and must be freed using the NetApiBufferFree function. Note that you must 292 * free the buffer even if the function fails with ERROR_MORE_DATA. 293 * @param prefmaxlen 294 * Specifies the preferred maximum length of returned data, in bytes. If you specify 295 * MAX_PREFERRED_LENGTH, the function allocates the amount of memory required for the 296 * data. If you specify another value in this parameter, it can restrict the number 297 * of bytes that the function returns. If the buffer size is insufficient to hold 298 * all entries, the function returns ERROR_MORE_DATA. 299 * @param entriesread 300 * Pointer to a value that receives the count of elements actually retrieved. 301 * @param totalentries 302 * Pointer to a value that receives the total number of entries that could have been retrieved. 303 * @return 304 * If the function succeeds, the return value is NERR_Success. 305 */ NetUserGetGroups(String servername, String username, int level, PointerByReference bufptr, int prefmaxlen, IntByReference entriesread, IntByReference totalentries)306 public int NetUserGetGroups(String servername, String username, int level, 307 PointerByReference bufptr, int prefmaxlen, 308 IntByReference entriesread, IntByReference totalentries); 309 310 /** 311 * The NetUserGetLocalGroups function retrieves a list of local groups to which a 312 * specified user belongs. 313 * @param servername 314 * Pointer to a constant string that specifies the DNS or NetBIOS name of the remote 315 * server on which the function is to execute. If this parameter is NULL, the local 316 * computer is used. 317 * @param username 318 * Pointer to a constant string that specifies the name of the user for which to return 319 * local group membership information. If the string is of the form DomainName\UserName 320 * the user name is expected to be found on that domain. If the string is of the form 321 * UserName, the user name is expected to be found on the server specified by the 322 * servername parameter. 323 * @param level 324 * Specifies the information level of the data. 325 * @param flags 326 * Specifies a bitmask of flags. Currently, only the value LG_INCLUDE_INDIRECT is 327 * defined. If this bit is set, the function also returns the names of the local 328 * groups in which the user is indirectly a member (that is, the user has membership 329 * in a global group that is itself a member of one or more local groups). 330 * @param bufptr 331 * Pointer to the buffer that receives the data. The format of this data depends on 332 * the value of the level parameter. This buffer is allocated by the system and must 333 * be freed using the NetApiBufferFree function. Note that you must free the buffer 334 * even if the function fails with ERROR_MORE_DATA. 335 * @param prefmaxlen 336 * Specifies the preferred maximum length of returned data, in bytes. If you specify 337 * MAX_PREFERRED_LENGTH, the function allocates the amount of memory required for the 338 * data. If you specify another value in this parameter, it can restrict the number of 339 * bytes that the function returns. If the buffer size is insufficient to hold all 340 * entries, the function returns ERROR_MORE_DATA. For more information, see Network 341 * Management Function Buffers and Network Management Function Buffer Lengths. 342 * @param entriesread 343 * Pointer to a value that receives the count of elements actually enumerated. 344 * @param totalentries 345 * Pointer to a value that receives the total number of entries that could have been enumerated. 346 * @return 347 * If the function succeeds, the return value is NERR_Success. 348 */ NetUserGetLocalGroups(String servername, String username, int level, int flags, PointerByReference bufptr, int prefmaxlen, IntByReference entriesread, IntByReference totalentries)349 public int NetUserGetLocalGroups(String servername, String username, int level, 350 int flags, PointerByReference bufptr, int prefmaxlen, 351 IntByReference entriesread, IntByReference totalentries); 352 353 /** 354 * The NetUserAdd function adds a user account and assigns a password and privilege level. 355 * @param servername 356 * Pointer to a constant string that specifies the DNS or NetBIOS name of the remote server 357 * on which the function is to execute. 358 * @param level 359 * Specifies the information level of the data. 360 * @param buf 361 * Pointer to the buffer that specifies the data. The format of this data depends on the 362 * value of the level parameter. 363 * @param parm_err 364 * Pointer to a value that receives the index of the first member of the user information 365 * structure that causes ERROR_INVALID_PARAMETER. If this parameter is NULL, the index is 366 * not returned on error. 367 * @return 368 * If the function succeeds, the return value is NERR_Success. 369 */ NetUserAdd(String servername, int level, Structure buf, IntByReference parm_err)370 public int NetUserAdd(String servername, int level, 371 Structure buf, IntByReference parm_err); 372 373 374 /** 375 * The NetUserDel function deletes a user account from a server. 376 * @param servername 377 * Pointer to a constant string that specifies the DNS or NetBIOS name of the remote 378 * server on which the function is to execute. If this parameter is NULL, the local 379 * computer is used. 380 * @param username 381 * Pointer to a constant string that specifies the name of the user account to delete. 382 * @return 383 * If the function succeeds, the return value is NERR_Success. 384 */ NetUserDel(String servername, String username)385 public int NetUserDel(String servername, String username); 386 387 /** 388 * The NetUserChangePassword function changes a user's password for a specified 389 * network server or domain. 390 * @param domainname 391 * Pointer to a constant string that specifies the DNS or NetBIOS name of a remote 392 * server or domain on which the function is to execute. If this parameter is NULL, 393 * the logon domain of the caller is used. 394 * @param username 395 * Pointer to a constant string that specifies a user name. The NetUserChangePassword 396 * function changes the password for the specified user. If this parameter is NULL, 397 * the logon name of the caller is used. 398 * @param oldpassword 399 * Pointer to a constant string that specifies the user's old password. 400 * @param newpassword 401 * Pointer to a constant string that specifies the user's new password. 402 * @return 403 * If the function succeeds, the return value is NERR_Success. 404 */ NetUserChangePassword(String domainname, String username, String oldpassword, String newpassword)405 public int NetUserChangePassword(String domainname, String username, 406 String oldpassword, String newpassword); 407 408 /** 409 * The DsGetDcName function returns the name of a domain controller in a specified domain. 410 * This function accepts additional domain controller selection criteria to indicate 411 * preference for a domain controller with particular characteristics. 412 * @param ComputerName 413 * Pointer to a null-terminated string that specifies the name of the server to process 414 * this function. Typically, this parameter is NULL, which indicates that the local 415 * computer is used. 416 * @param DomainName 417 * Pointer to a null-terminated string that specifies the name of the domain or application 418 * partition to query. This name can either be a DNS style name, for example, fabrikam.com, 419 * or a flat-style name, for example, Fabrikam. If a DNS style name is specified, the name 420 * may be specified with or without a trailing period. 421 * @param DomainGuid 422 * Pointer to a GUID structure that specifies the GUID of the domain queried. If DomainGuid 423 * is not NULL and the domain specified by DomainName or ComputerName cannot be found, 424 * DsGetDcName attempts to locate a domain controller in the domain having the GUID specified 425 * by DomainGuid. 426 * @param SiteName 427 * Pointer to a null-terminated string that specifies the name of the site where the returned 428 * domain controller should physically exist. If this parameter is NULL, DsGetDcName attempts 429 * to return a domain controller in the site closest to the site of the computer specified by 430 * ComputerName. This parameter should be NULL, by default. 431 * @param Flags 432 * Contains a set of flags that provide additional data used to process the request. 433 * @param DomainControllerInfo 434 * Pointer to a PDOMAIN_CONTROLLER_INFO value that receives a pointer to a 435 * DOMAIN_CONTROLLER_INFO structure that contains data about the domain controller selected. 436 * This structure is allocated by DsGetDcName. The caller must free the structure using 437 * the NetApiBufferFree function when it is no longer required. 438 * @return 439 * If the function returns domain controller data, the return value is ERROR_SUCCESS. 440 * If the function fails, the return code is one of ERROR_* values. 441 */ DsGetDcName(String ComputerName, String DomainName, GUID DomainGuid, String SiteName, int Flags, PDOMAIN_CONTROLLER_INFO DomainControllerInfo)442 public int DsGetDcName(String ComputerName, String DomainName, GUID DomainGuid, 443 String SiteName, int Flags, PDOMAIN_CONTROLLER_INFO DomainControllerInfo); 444 445 /** 446 * The DsGetForestTrustInformationW function obtains forest trust data for a specified domain. 447 * @param serverName 448 * Contains the name of the domain controller that DsGetForestTrustInformationW 449 * is connected to remotely. The caller must be an authenticated user on this server. 450 * If this parameter is NULL, the local server is used. 451 * @param trustedDomainName 452 * Contains the NETBIOS or DNS name of the trusted domain that the forest trust data 453 * is to be retrieved for. This domain must have the TRUST_ATTRIBUTE_FOREST_TRANSITIVE 454 * trust attribute. If this parameter is NULL, the forest trust data for the domain 455 * hosted by ServerName is retrieved. 456 * @param Flags 457 * Contains a set of flags that modify the behavior of this function. 458 * DS_GFTI_UPDATE_TDO: If this flag is set, DsGetForestTrustInformationW will update the 459 * forest trust data of the trusted domain identified by the TrustedDomainName parameter. 460 * @param ForestTrustInfo 461 * Pointer to an LSA_FOREST_TRUST_INFORMATION structure pointer that receives the forest 462 * trust data that describes the namespaces claimed by the domain specified by 463 * TrustedDomainName. The Time member of all returned records will be zero. 464 * @return 465 * Returns NO_ERROR if successful or a Win32 error code otherwise. 466 */ DsGetForestTrustInformation(String serverName, String trustedDomainName, int Flags, PLSA_FOREST_TRUST_INFORMATION ForestTrustInfo)467 public int DsGetForestTrustInformation(String serverName, String trustedDomainName, int Flags, 468 PLSA_FOREST_TRUST_INFORMATION ForestTrustInfo); 469 470 /** 471 * The DsEnumerateDomainTrusts function obtains domain trust data for a specified domain. 472 * @param serverName 473 * Pointer to a null-terminated string that specifies the name of a computer in the domain to 474 * obtain the trust information for. This computer must be running the Windows 2000 or later 475 * operating system. If this parameter is NULL, the name of the local computer is used. 476 * The caller must be an authenticated user in this domain. 477 * @param Flags 478 * Contains a set of flags that determines which domain trusts to enumerate. 479 * @param Domains 480 * Receives a pointer which points to an array of DS_DOMAIN_TRUSTS structures. 481 * Each structure in this array contains trust data about a domain. The caller must free this 482 * memory when it is no longer required by calling NetApiBufferFree. 483 * @param DomainCount 484 * Pointer to a ULONG value that receives the number of elements returned in the Domains array. 485 * @return 486 * Returns ERROR_SUCCESS if successful or a Win32 error code otherwise. 487 */ DsEnumerateDomainTrusts(String serverName, int Flags, PointerByReference Domains, IntByReference DomainCount)488 public int DsEnumerateDomainTrusts(String serverName, int Flags, 489 PointerByReference Domains, IntByReference DomainCount); 490 491 /** 492 * The NetUserGetInfo function retrieves information about a particular user account on a server. 493 * @param servername 494 * A pointer to a constant string that specifies the DNS or NetBIOS name of the remote server on 495 * which the function is to execute. If this parameter is NULL, the local computer is used. 496 * @param username 497 * A pointer to a constant string that specifies the name of the user account for which to return information. 498 * For more information, see the following Remarks section. 499 * @param level 500 * The information level of the data. This parameter can be one of the following values. 501 * Value Meaning 502 * 0 Return the user account name. The bufptr parameter points to a USER_INFO_0 structure. 503 * 1 Return detailed information about the user account. The bufptr parameter points to a USER_INFO_1 structure. 504 * 2 Return detailed information and additional attributes about the user account. The bufptr parameter points to a USER_INFO_2 structure. 505 * 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. 506 * 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. 507 * 10 Return user and account names and comments. The bufptr parameter points to a USER_INFO_10 structure. 508 * 11 Return detailed information about the user account. The bufptr parameter points to a USER_INFO_11 structure. 509 * 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. 510 * 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. 511 * @param bufptr 512 * A pointer to the buffer that receives the data. 513 * The format of this data depends on the value of the level parameter. 514 * This buffer is allocated by the system and must be freed using the NetApiBufferFree function. 515 * For more information, see Network Management Function Buffers and Network Management Function Buffer Lengths. 516 * @return 517 * If the function succeeds, the return value is NERR_Success. 518 */ NetUserGetInfo(String servername, String username, int level, PointerByReference bufptr)519 public int NetUserGetInfo(String servername, String username, int level, PointerByReference bufptr); 520 521 /** 522 * Shares a server resource. 523 * 524 * @param servername [in] 525 * Pointer to a string that specifies the DNS or NetBIOS name of the remote server on which the function is to execute. 526 * If this parameter is NULL, the local computer is used. 527 * @param level [in] 528 * Specifies the information level of the data. This parameter can be one of the following values: 529 * 2 - Specifies information about the shared resource, including the name of the resource, type and permissions, and number of connections. 530 * The buf parameter points to a SHARE_INFO_2 structure. 531 * 502 - Specifies information about the shared resource, including the name of the resource, type and permissions, number of connections, and other pertinent information. 532 * The buf parameter points to a SHARE_INFO_502 structure. 533 * 503 - Specifies information about the shared resource, including the name of the resource, type and permissions, number of connections, and other pertinent information. 534 * The buf parameter points to a SHARE_INFO_503 structure. 535 * @param buf [in] 536 * Pointer to the buffer that specifies the data. The format of this data depends on the value of the <code>level</code> parameter. 537 * For more information, see Network Management Function Buffers (https://msdn.microsoft.com/en-us/library/windows/desktop/aa370676(v=vs.85).aspx) 538 * @param parm_err [out] 539 * Pointer to a value that receives the index of the first member of the share information structure that causes the ERROR_INVALID_PARAMETER error. If this parameter is NULL, the 540 * index is not returned on error. For more information, see the NetShareSetInfo function. 541 * @return If the function succeeds, the return value is NERR_Success. If the function fails, the return value can be an error code as seen on MSDN. 542 */ NetShareAdd(String servername, int level, Pointer buf, IntByReference parm_err)543 public int NetShareAdd(String servername, int level, Pointer buf, IntByReference parm_err); 544 545 /** 546 * Deletes a share name from a server's list of shared resources, disconnecting all connections to the shared resource. 547 * 548 * @param servername [in] 549 * Pointer to a string that specifies the DNS or NetBIOS name of the remote server on which the function is to execute. 550 * If this parameter is NULL, the local computer is used. 551 * @param netname [in] 552 * Pointer to a string that specifies the name of the share to delete. 553 * @param reserved 554 * Reserved, must be zero. 555 * @return If the function succeeds, the return value is LMErr.NERR_Success. 556 * If the function fails, the return value can be an error code as seen on MSDN. 557 */ NetShareDel(String servername, String netname, int reserved)558 public int NetShareDel(String servername, String netname, int reserved); 559 } 560