Is there a way to get user information via the JavaScript Client OM? Something similar to the clientContext.Web.EnsureUser(userName)
method. I am aware that there is the SPService JQuery library, but if I can do this via the Client Object Model, I would prefer that. And just to be clear: I am NOT talking about the current logged in user. I want to verify the existence of a user in a manner similar to the people picker control.
Edit: Here is some example code... It assumes JQuery is loaded. Just plug it into an HTML Form webpart.
<input type="text" id="user-name"> <input type="button" id="myButton" value="check name" /> <script type="text/javascript"> $(document).ready($('#myButton').click(function(){ verifyUser($('#user-name').val()); })); function verifyUser(userName){ var context = new SP.ClientContext.get_current(); var web = context.get_web(); var user = web.ensureUser(userName); context.load(user); context.executeQueryAsync( function(sender, args) {showUserData(user);}, function(sender, args) {alert("Error: " + args.get_message());} ); } function showUserData(user){ $('#display-user-info').html('<tr><td>Name: '+user.get_title()+'</td><td> Email: '+user.get_email()+'</td></tr>' ); $('#user-name').val(user.get_title()); } </script> <table id="display-user-info"> </table>