Objective C Full Name to Logon Name - objective-c

I have a user's full name (like the one returned by NSFullUserName()). Is there any way in c or objective c to confert this to a logon name (like the one returned by NSUserName()).
However, I cannot use NSFullUserName() because the full name I have is not necessarily the name of the currently logged in user.

The login name (NSUserName) and the full/display name (NSFullUserName) have no automated relationship. A user, when creating an account or at any time afterward in System Preferences, can choose whatever they like for both names — so there's no way to generate one given the other and be guaranteed it's correct.

Related

Periscopedata - How to see whether a column is used in a dashboard

Our organization hundreds of Periscope daashboard that is generated from a database, named "Animal".
Now, let's suppose there is a table named "Puppy" with column name "is_spotted". Is there an easy way to find out whether "is_spotted" has been used to create a dashboard, without going through every single dashboards?

How do I check user by ID or Name?

I want to check if the message what I got comes form the particular user and I want to check him by his Name or ID, because for some users I don't know the Id yet. Is there a good way to do it?

Messages read by groups without own database table

I have this table used when a user writes a note.
When writing a note, the user specifies if a sell-department and/or a buy-department should receive the note.
Each user can create a Case (lets say its just a table with case_id and case_text). And the notes the users write are related to a case.
So the table NOTES is (postgres database) something like this:
ID
TEXT (the message itself)
USER_ID (the user that writes the note)
CASE_ID (the case_id for which the note is been written)
Short word about users:
There are "ordinary" users and those working on a department. This should not make big difference for the description here.
When an ordinary user writes a note, let's say he want both buy-department and sell-department to be included (being informed about the note/see the note).
What happens now is that there is another table called UserNotes. It looks like this:
ID
IS_READ
NOTE_ID
USER_ID
DEPARTMENT_ID
READ_AT_DATE
So ordinary user with id = 1 writes this note and in the code (as he tells sell and buy-departments have to be included) I search for all the users working at that specific sell-department and all those working at that specific buy-department. I then put all these users in the table UserNotes. With IS_READ false by default.
When a user in the specific sell-department reads the note, I will then change IS_READ for this user's entry in UserNotes.
This is how it works today. I don't think this is scalable. I'm already getting performance issues. I don't think it is important to know when a note has been read. So because of this I was thinking that maybe the following solution could work. Please have a look and tell me if it could be better and the current one or if you have some other suggestion please let me know:
I drop UserNotes table. I add a new filed in table Notes: READ_BY. Here I will update the field each time a user reads the note.
I don't know if I could use some postgres-specific thing, maybe making this field a json-string and searchable.

Check if a pair of values is already used and dont allow entering differenet pair that shares one of the values with already used pair

I have MS ACCESS 2010 database that I made for some of my co-workers. The purpose of the database is to gather manual information in more automated way about some employees (instead of emailing files or having to rely on buggy excel sharing features).
I managed to make sure that each user see only their own data using query as a mean of interfacing with user and checking windows api to get user name.
Now I have a specific problem that I don't know how to solve:
Table contains of 3 columns that user have to enter manually:
ID
Name
Location
ID is not ID of this table, its an ID from totally different system that I can not interface with so it have to be manually entered along with name as I need it later. ID is unique for each employee.
Now I made sure that user can not enter unique combination of those three columns twice using constrains (the same name/id can be used for different locations), but what is possible is that user enter the same ID with different name (not good), or the same name with different ID (possible as employees may have the same name).
Is there a way to check upon entering of data if a given ID exists with different name then the one entered by the user?
Example:
ID NAME LOCATION
123 Martin Warszawa - OK
123 Martin Kraków - OK (the same person assigned to his second location)
124 Martin Kraków - OK (same name as another guy from Kraków, but two different persons)
123 Paul Wrocław - NOT OK (ID points to Martin, so it should not be entered as Paul)
123 Martin Warszawa - NOT OK (duplicated first row - blocked with constrains)
Can this even be accomplished?
What I would want to retain is the ability to enter values by users in the query window and this as far as I know will be compromised if I change this into One:Many table relationship.
I assume that macro/sql procedure could be used to accomplish that and block insert attempt but I don't know how to accomplish it
Normalize your database. You have users identified by an ID (primary key bold):
users (id, name)
and their locations:
user_locations (user_id, location)
So there can be no longer be duplicate user entries and there can be no duplicate locations. If you want to add something, use INSERT. If that fails, it means the entry is already there. If you want to update something, use UPDATE. If you want to insert or update depending, try INSERT first; if this fails UPDATE. (You can search for upsert and MS-Access, and you will find how this is done).

Is there a "uniqueID" type property for address book contacts?

I'm making a game involving the user's contacts, but need a way to uniquely identify each contact. This is because the user can easily change the name, phone number, or other property of a given contact. Is there a way to do this?
You can use ABRecordGetRecordID() to get the unique ID of a record. It returns an ABRecordID which is a typedef for int32_t.
ABRecordGetRecordID() is the API that you can use. However, apple documentation does states some noteworthy points about the ABRecordID returned by this API.
Every record in the Address Book database has a unique record identifier. This identifier always refers to the same record, unless that record is deleted or the data is reset. Record identifiers can be safely passed between threads. They are not guaranteed to remain the same across devices.
The suggested method as per apple guidelines is
The recommended way to keep a long-term reference to a particular record is to store the first and last name, or a hash of the first and last name, in addition to the identifier. When you look up a record by ID, compare the record’s name to your stored name. If they don’t match, use the stored name to find the record, and store the new ID for the record.
In my app, I am also checking for creation date of the contact since the name against the ABRecordID could have been changed by the user. Creation date of a contact DOES NOT change upon device reset.
Though I have pasted most of the content here, its always advised to read the documentation