Get all Users with User License:
List<User> userList = [Select Id, Name, Profile.UserLicense.Name From User];
Get Users with specific User License:
List<User> userList = [Select Id, Name, Profile.UserLicense.Name From User WHERE Profile.UserLicense.Name = 'Salesforce'];