Kaydet (Commit) 41e5003f authored tarafından mertcelen's avatar mertcelen

Ldap Search reworked.

üst 94a5aac8
......@@ -29,7 +29,7 @@ class PermissionManager
// Loop through every validations
foreach(PermissionManager::$verify as $target){
if(!$this->check($target)){
return respond('Liman: Bu işlem için yetkiniz bulunmamaktadır.',403);
return respond('Bu işlem için yetkiniz bulunmamaktadır.',403);
}
}
// Process request if everything is ok.
......@@ -52,7 +52,6 @@ class PermissionManager
if($value == null){
return true;
}
echo $value;
if(!in_array($value, request('permissions')->__get($target))){
return false;
}
......
......@@ -47,6 +47,6 @@ class User extends Authenticatable
if($this->permissions->__get($target) == null){
return $this->isAdmin();
}
return array_search($id, $this->permissions->__get($target));
return in_array($id, $this->permissions->__get($target));
}
}
@foreach($files as $key => $file)
@if(is_array($file))
{ name: '{{$key}}', children: [@include('__system__.folder',["files" => $file])] },
{ "text" : "{{$key}}", "children" : [@include('__system__.folder',["files" => $file])]},
@else
{ name: '{{$file}}', children: [] },
{ "text" : "{{$file}}" },
@endif
@endforeach
\ No newline at end of file
......@@ -40,14 +40,16 @@
unset($t);
$mert = array_merge_recursive($mert,$res);
}
hello_world();
?>
<script src="{{asset('/js/treeview.min.js')}}"></script>
<link rel="stylesheet" href="{{asset('/css/tree.css')}}">
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/jstree/3.3.7/themes/default/style.min.css" />
<script src="//cdnjs.cloudflare.com/ajax/libs/jstree/3.3.7/jstree.min.js"></script>
<div class="container">
<div class="row">
<div class="col">
<div id="tree"></div>
<div id="ldap_tree"></div>
</div>
<div class="col pt-3">
<table class="table">
......@@ -77,18 +79,28 @@
</div>
</div>
</div>
<form id="s">
<input type="search" id="q" />
<button type="submit">Search</button>
</form>
<script>
function asd(){
$('#ldap_tree').jstree({
"plugins" : ["search"],
'core' : {
'data' : [
@include("__system__.folder",["files" => $mert])
]
}
});
}
asd();
</script>
<script>
let tree = new TreeView([
@include("__system__.folder",["files" => $mert])
], 'tree');
tree.on('select',function(e){
let cn = e.data.name;
document.getElementById("uid").innerText = user_details[cn]["uid"];
document.getElementById("uidnumber").innerText = user_details[cn]["uidnumber"];
document.getElementById("homedirectory").innerText = user_details[cn]["homedirectory"];
document.getElementById("gidnumber").innerText = user_details[cn]["gidnumber"];
document.getElementById("cn").innerText = user_details[cn]["cn"];
$("#s").submit(function(e) {
e.preventDefault();
$("#ldap_tree").jstree(true).search($("#q").val());
});
let user_details = <?php echo json_encode($user_details) ?>;
</script>
\ No newline at end of file
<?php
$ldap_connection = ldap_connect($server->ip_address);
ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, 0);
$query = "openssl s_client -connect " . $server->ip_address . ":" . $server->control_port .
" 2>/dev/null </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'";
$cert = shell_exec($query);
ldap_set_option($ldap_connection, LDAP_OPT_X_TLS_CACERTFILE,$cert);
ldap_set_option($ldap_connection, LDAP_OPT_X_TLS_REQUIRE_CERT, LDAP_OPT_X_TLS_HARD);
$pass = "SambaPardus01";
try{
$result = ldap_bind($ldap_connection,"administrator@win.lab",$pass);
$result = ldap_bind($ldap_connection,"cn=administrator,cn=Users,dc=win,dc=lab",$pass);
}catch (Exception $e){
dd($e->getMessage());
}
$search = ldap_search($ldap_connection, "dc=win,dc=lab" , "(objectclass=person)");
$users = ldap_get_entries($ldap_connection, $search);
$mert = [];
......@@ -46,15 +52,15 @@ for($i = 0 ; $i < $users["count"] ; $i++){
}
$user_details[$k]["cn"] = $attributes[0]["cn"][0];
$user_details[$k]["name"] = $attributes[0]["name"][0];
$user_details[$k]["sn"] = $attributes[0]["sn"][0];
$user_details[$k]["givenName"] = $attributes[0]["givenName"][0];
$user_details[$k]["samaccountname"] = $attributes[0]["samaccountname"][0];
$user_details[$k]["whenCreated"] = $attributes[0]["whenCreated"][0];
$user_details[$k]["whenChanged"] = $attributes[0]["whenChanged"][0];
$user_details[$k]["pwdLastSet"] = $attributes[0]["pwdLastSet"][0];
$user_details[$k]["lastLogon"] = $attributes[0]["lastLogon"][0];
$user_details[$k]["lastLogoff"] = $attributes[0]["lastLogoff"][0];
$user_details[$k]["accountExpires"] = $attributes[0]["accountExpires"][0];
// $user_details[$k]["sn"] = $attributes[0]["sn"][0];
// $user_details[$k]["givenName"] = $attributes[0]["givenName"][0];
// $user_details[$k]["samaccountname"] = $attributes[0]["samaccountname"][0];
// $user_details[$k]["whenCreated"] = $attributes[0]["whenCreated"][0];
// $user_details[$k]["whenChanged"] = $attributes[0]["whenChanged"][0];
// $user_details[$k]["pwdLastSet"] = $attributes[0]["pwdLastSet"][0];
// $user_details[$k]["lastLogon"] = $attributes[0]["lastLogon"][0];
// $user_details[$k]["lastLogoff"] = $attributes[0]["lastLogoff"][0];
// $user_details[$k]["accountExpires"] = $attributes[0]["accountExpires"][0];
}
$t = &$t[$k];
......@@ -131,16 +137,16 @@ for($i = 0 ; $i < $users["count"] ; $i++){
tree.on('select',function(e){
let cn = e.data.name;
document.getElementById("cn").innerText = user_details[cn]["cn"];
document.getElementById("whencreated").innerText = user_details[cn]["whencreated"];
document.getElementById("whenchanged").innerText = user_details[cn]["whenchanged"];
// document.getElementById("whencreated").innerText = user_details[cn]["whencreated"];
// document.getElementById("whenchanged").innerText = user_details[cn]["whenchanged"];
document.getElementById("name").innerText = user_details[cn]["name"];
document.getElementById("sn").innerText = user_details[cn]["sn"];
document.getElementById("givenName").innerText = user_details[cn]["givenName"];
document.getElementById("samaccountname").innerText = user_details[cn]["samaccountname"];
document.getElementById("pwdLastSet").innerText = user_details[cn]["pwdLastSet"];
document.getElementById("lastLogon").innerText = user_details[cn]["lastLogon"];
document.getElementById("lastLogoff").innerText = user_details[cn]["lastLogoff"];
document.getElementById("accountExpires").innerText = user_details[cn]["accountExpires"];
// document.getElementById("sn").innerText = user_details[cn]["sn"];
// document.getElementById("givenName").innerText = user_details[cn]["givenName"];
// document.getElementById("samaccountname").innerText = user_details[cn]["samaccountname"];
// document.getElementById("pwdLastSet").innerText = user_details[cn]["pwdLastSet"];
// document.getElementById("lastLogon").innerText = user_details[cn]["lastLogon"];
// document.getElementById("lastLogoff").innerText = user_details[cn]["lastLogoff"];
// document.getElementById("accountExpires").innerText = user_details[cn]["accountExpires"];
});
let user_details = <?php echo json_encode($user_details) ?>;
</script>
\ No newline at end of file
......@@ -4,9 +4,9 @@
@include('title',[
"title" => "Betikler"
])
<button type="button" class="btn btn-success" onclick="window.location.href = '{{route('script_add')}}'">
{{ __("Betik Oluştur") }}
</button>
{{--<button type="button" class="btn btn-success" onclick="window.location.href = '{{route('script_add')}}'">--}}
{{--{{ __("Betik Oluştur") }}--}}
{{--</button>--}}
@include('modal-button',[
"class" => "btn-primary",
......@@ -32,7 +32,8 @@
</thead>
<tbody>
@foreach ($scripts as $script)
<tr class="highlight" onclick="window.location.href = '{{route('script_one',$script->_id)}}'">
{{--<tr class="highlight" onclick="window.location.href = '{{route('script_one',$script->_id)}}'">--}}
<tr class="">
<td>{{$script->name}}</td>
</tr>
@endforeach
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment