Basit Khan

Basit Khan

  • NA
  • 336
  • 121.8k

DataServices get current user name.

Sep 7 2015 4:31 AM
Dear,
 
I have created data services, below is my login code working fine.
 
ar _url = "http://localhost/CMWeb/DataService.svc/Users?$filter=UserName eq '" + "Basit" + "' and Password eq '" + "s" + "'&$format=json";
UserAdmin = 0,
$.ajax({
type: "GET",
url: _url,
timeout: 10000,
async: false,
dataType: "json",
contentType: "application/jsonp; charset=utf-8",
success: function (data) {
debugger;
if (data.d.length > 0 && data.d[0].UserEnabled == 1) {
UserAdmin = data.d[0].UserAdmin
//redirect to main page
} else {
//show alter message.
}
},
error: function (xhr, status, error) {
}
});
In Data services DataService.svc
After login i want to get current user
that's why i wrote
Hide Copy Code
<QueryInterceptor("CustomersCalls")> _
Public Function OnQueryOrders() As Expression(Of Func(Of CustomersCall, Boolean))
'Dim User As System.Security.Principal.IPrincipal
'User = System.Web.HttpContext.Current.User
'Dim user = Membership.GetUser(HttpContext.Current.User.Identity.Name)
Return Function(c) c.CreatedBy = User.Identity.Name
End Function
but i got only computer name, how to get the current user.
Thanks
Basit.
 

Answers (2)