Skip to content

Commit

Permalink
Merge pull request #178 from davidmc24/platform-userinfo10
Browse files Browse the repository at this point in the history
platform: add mapping of USER_INFO_10 structure to LMAccess
  • Loading branch information
dblock committed Jan 20, 2013
2 parents bc67864 + 8da7dc2 commit 3f7e52a
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
====================
Expand Down
44 changes: 44 additions & 0 deletions contrib/platform/src/com/sun/jna/platform/win32/LMAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
21 changes: 18 additions & 3 deletions contrib/platform/test/com/sun/jna/platform/win32/Netapi32Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -249,7 +264,7 @@ public void testDsEnumerateDomainTrusts() {
assertTrue(Ole32Util.getStringFromGUID(trust.DomainGuid).startsWith("{"));
}



assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree(domainTrustRefs.getPointer()));
}

Expand Down

0 comments on commit 3f7e52a

Please sign in to comment.