Bonjour,
Je souhaiterai lister dans la partie USER de mon site internet en PHP, tous les utilisateurs de l’active directory. Je sais que c’est possible, mais après plusieurs recherche sur le net, je ne comprends toujours pas comment faire… Peut-être que quelqu’un pourrait m’éclaircir la situation ?
Pour le moment ma page user.php ressemble à ça. J’ai une partie PHP et du JAVASCRIPT. Et pour le moment je peux ajouter des utilisateurs depuis cette page manuellement. Et donc mon but serait d’enlever ça, et de la remplacer par la liste d’user Active Directory…
<!DOCTYPE html>
<html>
<head>
<title>ArcadSoftware : User</title>
<link rel="icon" href="includes/img/favicon.ico" />
<?php require_once 'includes/header.php';?>
</head>
<body ng-app="crudApp" ng-controller="crudController">
<?php
// We call header and the functions
require_once 'database_connection.php';
require_once 'includes/function.php';
?>
<div class="container" ng-init="fetchData()">
<br />
<h2>User</h2>
<br />
<div class="alert alert-success alert-dismissible" ng-show="success" >
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
{{successMessage}}
</div>
<div align="right">
<!-- Button ADD USER -->
<button type="button" name="add_button" ng-click="addData()" class="btn btn-success">Add a new user</button>
</div>
<br />
<div class="table-responsive" style="overflow-x: unset;">
<table datatable="ng" dt-options="vm.dtOptions" class="table table-bordered table-striped">
<thead>
<!-- Name of the tables -->
<tr>
<th>Name</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<!-- The tables -->
<tr ng-repeat="name in namesData">
<td>{{name.user_name}}</td>
<td><button type="button" ng-click="fetchSingleData(name.id)" class="btn btn-warning btn-xs">EDIT</button></td>
<td><button type="button" ng-click="deleteData(name.id)" class="btn btn-danger btn-xs">DELETE</button></td>
</tr>
</tbody>
</table>
</div>
<!-- Button UP -->
<input class="btn btn-primary btn-sm active" type="button" value="UP" id="myButton" />
<br /><br />
</div>
<!-- Call footer.php -->
<?php require_once 'includes/footer.php'; ?>
<br /><br />
</body>
</html>
<!-- ADD USER NAME -->
<div class="modal fade" tabindex="-1" role="dialog" id="crudmodal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form method="post" ng-submit="submitForm()">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">{{modalTitle}}</h4>
</div>
<div class="modal-body">
<div class="alert alert-danger alert-dismissible" ng-show="error" >
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
{{errorMessage}}
</div>
<div class="form-group">
<label>Enter user name</label>
<input type="text" name="user_name" ng-model="user_name" class="form-control" />
</div>
<div class="modal-footer">
<input type="hidden" name="hidden_id" value="{{hidden_id}}" />
<input type="submit" name="submit" id="submit" class="btn btn-info" value="{{submit_button}}" />
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</form>
</div>
</div>
</div>
<!-- JAVASCRIPT -->
<script>
var app = angular.module('crudApp', ['datatables']);
app.controller('crudController', function($scope, $http){
$scope.success = false;
$scope.error = false;
$scope.fetchData = function(){
$http.get('fetch_data.php?name=user').success(function(data){
$scope.namesData = data;
});
};
$scope.openModal = function(){
var modal_popup = angular.element('#crudmodal');
modal_popup.modal('show');
};
$scope.closeModal = function(){
var modal_popup = angular.element('#crudmodal');
modal_popup.modal('hide');
};
$scope.addData = function(){
$scope.modalTitle = 'Add a new user';
$scope.submit_button = 'Insert';
$scope.openModal();
};
$scope.submitForm = function(){
$http({
method:"POST",
url:"insert.php",
data:{'user_name':$scope.user_name, 'action':$scope.submit_button, 'id':$scope.hidden_id}
}).success(function(data){
if(data.error != '')
{
$scope.success = false;
$scope.error = true;
$scope.errorMessage = data.error;
}
else
{
$scope.success = true;
$scope.error = false;
$scope.successMessage = data.message;
$scope.form_data = {};
$scope.closeModal();
$scope.fetchData();
}
});
};
$scope.fetchSingleData = function(id){
$http({
method:"POST",
url:"insert.php",
data:{'id':id, 'action':'fetch_single_data'}
}).success(function(data){
$scope.user_name = data.user_name;
$scope.hidden_id = id;
$scope.modalTitle = 'Edit the user name';
$scope.submit_button = 'Edit';
$scope.openModal();
});
};
$scope.deleteData = function(id){
if(confirm("Are you sure you want to remove it?"))
{
$http({
method:"POST",
url:"insert.php",
data:{'id':id, 'action':'Delete'}
}).success(function(data){
$scope.success = true;
$scope.error = false;
$scope.successMessage = data.message;
$scope.fetchData();
});
}
};
});
</script>
+0
-0