Show first and last name instead of JID - xmpp

I'm working on a chat using XMPP.
And when I try to load the users with their names who are part of the roster on XMPP, it always shows only the username, which is the JID, instead of the name although I specified that I want to retrieve the name attribute with the following:
var jid = $(this).attr('jid');
var name = $(this).attr('name');
And I did specify in the System Properties under Server Manager in Openfire the following:
jdbcUserProvider.nameField --> first_name
nameField --> first_name
But it keeps on showing me the user's username, which is the JID that is registered in the DB.

Related

Fetch user identities from TFS using C# REST API

In OM API as we used to fetch user identities and we can put search on multiple values for example:
when we set IdentitySearchFilter = IdentitySearchFilter.DisplayName we were able to give multiple user display names to fetch multiple users, how can we achieve this in C# REST API, because it is accepting only one display name to fetch its user?
IdentitiesCollection identities =
identityHttpClient.ReadIdentitiesAsync(IdentitySearchFilter.DisplayName, displayName[0]).Result;
I have a list of displayNames to fetch users in one call to TFS.
Below code will help you to fetch all the user list:
foreach(var displayName in displayNames)
{
var result = await client.ReadIdentitiesAsync(IdentitySearchFilter.DisplayName, displayName).Result;
}
OR
foreach(var displayName in displayNames)
{
IdentitiesCollection identities = identityHttpClient.ReadIdentitiesAsync(IdentitySearchFilter.DisplayName, displayName).Result;
}
Refer this similar SO Thread and MSFT documentation to get all the users in a given scope and this is for getting direct members in a group.

CRM 2013 - Plugin to retrieve username

I have an AutoNumber plug-in that invokes when the user presses save, but I've received a requirement to append the initials of the person creating the record to the end of the ticket.
For example: 0001-0327-RBS
I have been able to get the GUID of the user creating the record, but I have no idea how to get the literal value outside of SQL. I haven't been able to figure out how I can get the user name of the active user creating the record. Is this possible from within a plug-in?
any help is appreciated. thanks.
You should get IOrganizationService from IServiceProvider
var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
var serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
var service = serviceFactory.CreateOrganizationService(context.UserId);
now you can simply retrieve the SystemUser using the service:
var systemUser = service.Retrieve("systemuser", context.UserId, new Microsoft.Xrm.Sdk.Query.ColumnSet(true));
in ColumnSet you can specify the columns which you want to retrieve (so for example "firstname", "lastname", "fullname" etc.).
Now you can simply do
systemUser["fullname"]
to get the name. Or if you are using early binds:
systemUser.ToEntity<SystemUser>().FullName

Get Username using GUID in Sugarcrm

I have an issue with my SugarCRM reset password page. When a user visits the Reset Password form through the link provided through mail, he/she has to put the username. If the username is kept empty the form gets submitted but the password doesn't change.
I want to either make username required field or fetch the username using GUID. Thanks.
$user = BeanFactory::getBean('Users',$guid);
$username = $user->user_name;
The guid included in the password reset link is not the guid for that user (that would be a security risk). Instead, it is a guid to the users_password_link table. If you are using the guid passed in from such a link, then you could find the username by the following SQL statement:
select users.user_name from users join users_password_link on users_password_link.username = users.user_name where users_password_link.id = '$guid';
If you were working with the user's actual guid, egg's answer is the correct way to find the information using SugarCRM's best practices.

Extend User authentication object in Azure Mobile Services

Is it possible to add additional properties to the User object on the server in WAMS? I would like to store the Id primary key of my User table for (secure) use in my table scripts. At the moment the only id is the vendor specific authentication Id, but I'd like to be able to allow users to choose an authentication method. Currently my (simplified) table design is as follows:
User table:
id
googleId
twitterId
facebookId
name, etc...
League table
id
userId
name, etc
I'd like to store the user primary key in the userId field on the league table, and then query it to ensure that users only get to see leagues they created. At the moment, the user object in table scripts sends through a User object with the Google/Twitter/Windows authentication token and I have to do a query to get the primary key userID, everytime I want to carry out an operation on a table with a userId column.
Ideal solution would be that when the Insert script on my User table is called on registrations and logins I can do:
// PSEUDO CODE
function insert(item, user, request) {
var appUserId;
Query the user table using the user.userId Google/Twitter/Facebook id
If user exists {
// Set a persisted appUserId to use in all subsequent table scripts.
user.appUserId = results.id;
} else {
Set the GooTwitFace columns on the user table, from user.userId
insert the user then get the inserted record id
// Set a persisted appUserId to use in all subsequent table scripts
user.appUserId = insertUserPK;
}
}
Then, in subsequent table scripts, I'd like to use user.appUserId in queries
If all you are trying to do is authorize users to only have access to their own data, I'm not sure you even need the "user" table. Just use the provider-specific userId on the user object to query your "league" table (making sure the userId column is indexed). The values will be provider-specific, but that shouldn't make any difference.
If you are trying to maintain a notion of a single user identity across the user's Google/Facebook/Twitter logins, that's a more complicated problem where you would need a "user" table and the kind of lookup you are describing. We hope to ship support for this scenario as a feature out of the box. It is possible (but fairly messy) to do this yourself, let me know if that's what you're trying to do.

How to get data from relationship objects in entity framework?

I have 2 Entity objects that i mapped in Entityframework
I have relationship between users and Messages
I want to get all messages of specific user so i load the data from users table to specific user object:
var user = (from u in context.Users
where u.u_username == username
select u).First();
Now, how can i get all messages of this user , i notice that i can do:
var messages = user.Messages;
But i got nothing.
Is it correct?
How can i used this syntax and to get all message of the specific user?
I used .net4
Is it possible to do
If you want to lazy load the Messages of the user you can make the Messages property virtual.
public class User
{
//other properties
public virtual ICollection<Message> Messages;
}
Or you can eager load Messages using Include function
var user = (from u in context.Users.Include("Messages")
where u.u_username == username
select u).First();
Finally it maybe the case that you have not configured the Messages property with EF.