Case
When you want to get the user list through BS2_GetUserListUser. (Device SDK C#)
Information
Function :extern public static int BS2_GetUserList(IntPtr context, UInt32 deviceId, out IntPtr outUidObjs, out UInt32 outNumUids, IsAcceptableUserID cbIsAcceptableUserID)
Order : Call the Function -> BS2_GetUserData function after BS2_GetUserList
Parameter
value | Explanation |
---|---|
0x0000 | user identifier |
0x0001 | user data |
0x0002 | user settings |
0x0004 | username |
0x0008 | image |
0x0010 | PIN |
0x0020 | card |
0x0040 | Fingerprint |
0x0080 | Face |
0x0100 | access group |
0x0200 | working code |
0x0400 | personal message |
0x0800 | Face (FaceStation F2) |
0x1000 | Custom (FaceStation F2) |
0xFFFF | All user information |
If successfully done, BS_SDK_SUCCESS
will be returned.
If there is an error, the corresponding error code will be returned.
Sample Code
public void listUserFromDevice(IntPtr sdkContext, UInt32 deviceID, bool isMasterDevice) { IntPtr outUidObjs = IntPtr.Zero; UInt32 numUserIds = 0; API.IsAcceptableUserID cbIsAcceptableUserID = null; // we don't need to user id filtering Console.WriteLine("Trying to get user list."); BS2ErrorCode result = (BS2ErrorCode)API.BS2_GetUserList(sdkContext, deviceID, out outUidObjs, out numUserIds, cbIsAcceptableUserID); if (result == BS2ErrorCode.BS_SDK_SUCCESS) { if (numUserIds > 0) { IntPtr curUidObjs = outUidObjs; BS2UserBlob[] userBlobs = new BS2UserBlob[USER_PAGE_SIZE]; Console.WriteLine("Number of users : ({0}).", numUserIds); for (UInt32 idx = 0; idx < numUserIds;) { UInt32 available = numUserIds - idx; if (available > USER_PAGE_SIZE) { available = USER_PAGE_SIZE; } result = (BS2ErrorCode)API.BS2_GetUserDatas(sdkContext, deviceID, curUidObjs, available, userBlobs, (UInt32)BS2UserMaskEnum.ALL); if (result == BS2ErrorCode.BS_SDK_SUCCESS) { for (UInt32 loop = 0; loop < available; ++loop) { print(sdkContext, userBlobs[loop].user); // don't need to release cardObj, FingerObj, FaceObj because we get only BS2User if (userBlobs[loop].cardObjs != IntPtr.Zero) API.BS2_ReleaseObject(userBlobs[loop].cardObjs); if (userBlobs[loop].fingerObjs != IntPtr.Zero) API.BS2_ReleaseObject(userBlobs[loop].fingerObjs); if (userBlobs[loop].faceObjs != IntPtr.Zero) API.BS2_ReleaseObject(userBlobs[loop].faceObjs); } idx += available; curUidObjs += (int)available * BS2Environment.BS2_USER_ID_SIZE; } else { Console.WriteLine("Got error({0}).", result); break; } } API.BS2_ReleaseObject(outUidObjs); } } else { Console.WriteLine("Got error({0}).", result); return; } }
Result In SDK