From c7e96bd3c0a15bc02edd36ab4b5db4683250ad31 Mon Sep 17 00:00:00 2001 From: "David M. Carr" Date: Sat, 19 Jan 2013 22:20:45 -0500 Subject: [PATCH 1/3] platform: add mapping of USER_INFO_10 structure to LMAccess --- .../com/sun/jna/platform/win32/LMAccess.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/contrib/platform/src/com/sun/jna/platform/win32/LMAccess.java b/contrib/platform/src/com/sun/jna/platform/win32/LMAccess.java index 10b4b41c75..9a77e5a921 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/LMAccess.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/LMAccess.java @@ -154,6 +154,50 @@ protected List getFieldOrder() { return Arrays.asList(new String[] { "usri1_name", "usri1_password", "usri1_password_age", "usri1_priv", "usri1_home_dir", "usri1_comment", "usri1_flags", "usri1_script_path" }); } } + + /** + * The USER_INFO_10 structure contains information about a user account, + * including the account name, comments associated with the account, and + * the user's full name. + */ + public static class USER_INFO_10 extends Structure { + public USER_INFO_10() { + super(); + } + + public USER_INFO_10(Pointer memory) { + super(memory); + read(); + } + + /** + * Pointer to a Unicode string that specifies the name of the user + * account. Calls to the NetUserSetInfo function ignore this member. + */ + public WString usri10_name; + /** + * Pointer to a Unicode string that contains a comment associated with + * the user account. The string can be a null string, or can have any + * number of characters before the terminating null character. + */ + public WString usri10_comment; + /** + * Pointer to a Unicode string that contains a user comment. This + * string can be a null string, or it can have any number of characters + * before the terminating null character. + */ + public WString usri10_usr_comment; + /** + * Pointer to a Unicode string that contains the full name of the user. + * This string can be a null string, or it can have any number of + * characters before the terminating null character. + */ + public WString usri10_full_name; + + protected List getFieldOrder() { + return Arrays.asList(new String[] { "usri10_name", "usri10_comment", "usri10_usr_comment", "usri10_full_name" }); + } + } /** * The USER_INFO_23 structure contains information about a user account, From 811d025b888b49451fb7eadc04e03a88ccdb7f98 Mon Sep 17 00:00:00 2001 From: "David M. Carr" Date: Sat, 19 Jan 2013 22:27:09 -0500 Subject: [PATCH 2/3] platform tests: add coverage for Netapi32.NetUserEnum with user level 10 --- .../sun/jna/platform/win32/Netapi32Test.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/contrib/platform/test/com/sun/jna/platform/win32/Netapi32Test.java b/contrib/platform/test/com/sun/jna/platform/win32/Netapi32Test.java index 3e469a96c6..77a1d5a5ba 100644 --- a/contrib/platform/test/com/sun/jna/platform/win32/Netapi32Test.java +++ b/contrib/platform/test/com/sun/jna/platform/win32/Netapi32Test.java @@ -21,6 +21,7 @@ import com.sun.jna.platform.win32.LMAccess.GROUP_USERS_INFO_0; import com.sun.jna.platform.win32.LMAccess.LOCALGROUP_USERS_INFO_0; import com.sun.jna.platform.win32.LMAccess.USER_INFO_1; +import com.sun.jna.platform.win32.LMAccess.USER_INFO_10; import com.sun.jna.platform.win32.NTSecApi.LSA_FOREST_TRUST_RECORD; import com.sun.jna.platform.win32.NTSecApi.PLSA_FOREST_TRUST_INFORMATION; import com.sun.jna.platform.win32.NTSecApi.PLSA_FOREST_TRUST_RECORD; @@ -130,7 +131,7 @@ public void testNetGroupEnum() { assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue())); } - public void testNetUserEnum() { + public void testNetUserEnum1() { PointerByReference bufptr = new PointerByReference(); IntByReference entriesread = new IntByReference(); IntByReference totalentries = new IntByReference(); @@ -142,7 +143,21 @@ public void testNetUserEnum() { assertTrue(ui.usri1_name.length() > 0); } assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue())); - } + } + + public void testNetUserEnum10() { + PointerByReference bufptr = new PointerByReference(); + IntByReference entriesread = new IntByReference(); + IntByReference totalentries = new IntByReference(); + assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserEnum( + null, 10, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries, null)); + USER_INFO_10 userinfo = new USER_INFO_10(bufptr.getValue()); + USER_INFO_10[] userinfos = (USER_INFO_10[]) userinfo.toArray(entriesread.getValue()); + for (USER_INFO_10 ui : userinfos) { + assertTrue(ui.usri10_name.length() > 0); + } + assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue())); + } public void testNetUserAdd() { USER_INFO_1 userInfo = new USER_INFO_1(); @@ -249,7 +264,7 @@ public void testDsEnumerateDomainTrusts() { assertTrue(Ole32Util.getStringFromGUID(trust.DomainGuid).startsWith("{")); } - + assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree(domainTrustRefs.getPointer())); } From 8da7dc2e56122cd9032e88d69375fbd5379a3774 Mon Sep 17 00:00:00 2001 From: "David M. Carr" Date: Sun, 20 Jan 2013 15:00:26 -0500 Subject: [PATCH 3/3] changes: add entry for addition of USER_INFO_10 --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 943fe3c06d..dd0f14e929 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ Features * [#163](https://github.com/twall/jna/pull/163): Ported Win32 `dbt.h` - [@wolftobias](https://github.com/wolftobias). * [#163](https://github.com/twall/jna/pull/163): Added Win32 `WTSRegisterSessionNotification` and `WTSUnRegisterSessionNotification` from `Wtsapi32.dll` - [@wolftobias](https://github.com/wolftobias). * [#163](https://github.com/twall/jna/pull/163): Added Win32 `native_window_msg` that creates windows, registers for USB device and logon/logoff notifications - [@wolftobias](https://github.com/wolftobias). +* [#178](https://github.com/twall/jna/pull/178): Added Win32 `USER_INFO_10` structure from `LMAccess.h` - [@davidmc24](https://github.com/davidmc24). Release 3.5.1 ====================