0% found this document useful (0 votes)
87 views3 pages

Directory Services: Var New

This document provides instructions for implementing server-side pagination with jQuery DataTables. It explains how to enable server-side processing by setting the 'serverSide' option to true and providing an Ajax data source. On the client-side, DataTables is initialized and Ajax, searching, processing, serverSide, and language options are configured. On the server-side, a POST method returns the draw, recordsFiltered, recordsTotal, and paginated data to the DataTables Ajax request.

Uploaded by

Sana samad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views3 pages

Directory Services: Var New

This document provides instructions for implementing server-side pagination with jQuery DataTables. It explains how to enable server-side processing by setting the 'serverSide' option to true and providing an Ajax data source. On the client-side, DataTables is initialized and Ajax, searching, processing, serverSide, and language options are configured. On the server-side, a POST method returns the draw, recordsFiltered, recordsTotal, and paginated data to the DataTables Ajax request.

Uploaded by

Sana samad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Directory Services

Using Directory Services in OIS Framework, you will be able to validate or get information about certain
user on domain.

First you need to get information of gateway from DB for which you want to use, then use the
information fetched to initialize required directory service like ‘LdapService’ and then use its methods
appropriately as follows:
var authGatewayResponse = new
OIS.Framework.Services.Security.AuthGatewayService().Get(“YourGatewayId”);

if (authGatewayResponse.IsSuccess)
{
var gateway = authGatewayResponse.Payload;

var gwUrl = $"LDAP://{gateway.Url}";


var gwUsername = gateway.Username;
var gwPassword = gateway.Password;

var gatewayService = new OIS.Framework.DirectoryServices.LdapService(gwUrl,


gwUsername, gwPassword);

//Note: ‘gwUsername’ and ‘gwPassword’ will be Service account to log in to the


//domain

//Then call the method ‘GetProfileByUsername’ by giving the username of the which
//you need to get information from directory.

var userProfileVm = gatewayService.GetProfileByUsername(username);

//Also you can use method ‘ValidateUser’ to validate a certain user based on
//username and password.

var isAuthorized = gatewayService.ValidateUser(username, password);


}

Data Table Server-Side Pagination


While using jQuery DataTable plugin, you can use server-side pagination option by following this guide.

Server-side processing is enabled by setting the ‘serverSide’ option to ‘true’ and providing an Ajax data
source through the ajax option.

In your .cshtml file add table as follows:


<table id="tableId" class="display" cellspacing="0">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Gender</th>
</tr>
</thead>
<tbody></tbody>
</table>

In JavaScript, initialize data table as follows:


$('#tableId).DataTable({
'ajax': {
"type": "POST",
"url": 'GetAllData',
"datatype": "json"
},
searching: false,
"processing": true,
"serverSide": true,
"language": {
"emptyTable": "No record found."
},

columns: [
{
"width": "10%",
data: "Name",
name: "Name",
orderable: true
},
{
"width": "15%",
data: "Email",
name: "Email",
orderable: true
},
{
"width": "15%",
data: "Gender",
name: " Gender ",
orderable: true
}
]
});

On server side, write method like below, notice it should be http post so that it can get values from
request.
[HttpPost]
public JsonResult GetAllData()
{
var draw = Request.Form.GetValues("draw").FirstOrDefault();
var start = Request.Form.GetValues("start").FirstOrDefault();
var length = Request.Form.GetValues("length").FirstOrDefault();
int pageSize = length != null ? Convert.ToInt32(length) : 0;

int skip = start != null ? Convert.ToInt32(start) : 0;

//Find Order Column


var sortColumn = Request.Form.GetValues("columns[" +
Request.Form.GetValues("order[0][column]").FirstOrDefault() +
"][name]").FirstOrDefault();
var sortColumnDir = Request.Form.GetValues("order[0][dir]").FirstOrDefault();

var datatableVm = new OIS.Framework.ViewModels.DataTable.DataTableVm


{
PageSize = pageSize,
Skip = skip,
SortColumn = sortColumn,
SortDir = sortColumnDir
};

var result = ClientService.PostAsync<


OIS.Framework.ViewModels.DataTable.DTResult<DataVm>>(EndPoints.AllData,
datatableVm);

return Json(new { draw = draw, recordsFiltered = result.Payload.recordsFiltered,


recordsTotal = result.Payload.recordsTotal, data = result.Payload.data },
JsonRequestBehavior.AllowGet);
}

You might also like