Console.WriteLine("Enter the ID for the User which you want to remove"); Console.Write(">>>> "); string userID = Console.ReadLine(); if (userID.Length == 0) { Console.WriteLine("The user id can not be empty."); return; } else if (userID.Length > BS2Environment.BS2_USER_ID_SIZE) { Console.WriteLine("The user id should less than {0} words.", BS2Environment.BS2_USER_ID_SIZE); return; } else { byte[] uidArray = new byte[BS2Environment.BS2_USER_ID_SIZE]; byte[] rawUid = Encoding.UTF8.GetBytes(userID); IntPtr uids = Marshal.AllocHGlobal(BS2Environment.BS2_USER_ID_SIZE);
Array.Clear(uidArray, 0, BS2Environment.BS2_USER_ID_SIZE); Array.Copy(rawUid, 0, uidArray, 0, rawUid.Length); Marshal.Copy(uidArray, 0, uids, BS2Environment.BS2_USER_ID_SIZE);
Console.WriteLine("Trying to remove a user."); result = (BS2ErrorCode)API.BS2_RemoveUser(sdkContext, deviceID, uids, 1);
Marshal.FreeHGlobal(uids); }
C