Skip to content

platform: add mapping of USER_INFO_10 structure to LMAccess #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 20, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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