Search in sources :

Example 1 with USER_INFO_23

use of com.sun.jna.platform.win32.LMAccess.USER_INFO_23 in project jna by java-native-access.

the class Netapi32Util method getUserInfo.

public static UserInfo getUserInfo(String accountName, String domainName) {
    PointerByReference bufptr = new PointerByReference();
    int rc = -1;
    try {
        rc = Netapi32.INSTANCE.NetUserGetInfo(domainName, accountName, (short) 23, bufptr);
        if (rc == LMErr.NERR_Success) {
            USER_INFO_23 info_23 = new USER_INFO_23(bufptr.getValue());
            UserInfo userInfo = new UserInfo();
            if (info_23.usri23_comment != null) {
                userInfo.comment = info_23.usri23_comment.toString();
            }
            userInfo.flags = info_23.usri23_flags;
            if (info_23.usri23_full_name != null) {
                userInfo.fullName = info_23.usri23_full_name.toString();
            }
            if (info_23.usri23_name != null) {
                userInfo.name = info_23.usri23_name.toString();
            }
            if (info_23.usri23_user_sid != null) {
                userInfo.sidString = Advapi32Util.convertSidToStringSid(info_23.usri23_user_sid);
            }
            userInfo.sid = info_23.usri23_user_sid;
            return userInfo;
        } else {
            throw new Win32Exception(rc);
        }
    } finally {
        if (bufptr.getValue() != Pointer.NULL) {
            Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
        }
    }
}
Also used : PointerByReference(com.sun.jna.ptr.PointerByReference) USER_INFO_23(com.sun.jna.platform.win32.LMAccess.USER_INFO_23)

Aggregations

USER_INFO_23 (com.sun.jna.platform.win32.LMAccess.USER_INFO_23)1 PointerByReference (com.sun.jna.ptr.PointerByReference)1