|
|
|
@ -16,11 +16,11 @@ class Auth extends Controller
|
|
|
|
|
{ |
|
|
|
|
$session = session(); |
|
|
|
|
$model = new Mauth(); |
|
|
|
|
$uname = $this->request->getVar('username'); |
|
|
|
|
$password = $this->request->getVar('password'); |
|
|
|
|
$username = $this->request->getVar('username'); |
|
|
|
|
//$password = $this->request->getVar('password'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$param = array('name' => $uname, 'passwd' => $password); |
|
|
|
|
$data = $model->cekuser($param)->getRowArray(); |
|
|
|
|
$data = $model->cekuser($username)->getRowArray(); |
|
|
|
|
// var_dump($data); |
|
|
|
|
//exit(); |
|
|
|
|
if ($data) { |
|
|
|
@ -45,6 +45,94 @@ class Auth extends Controller
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function ldap_auth() |
|
|
|
|
{ |
|
|
|
|
$username = $this->request->getVar('username'); |
|
|
|
|
$password = $this->request->getVar('password'); |
|
|
|
|
$session = session(); |
|
|
|
|
if ($password == "") return redirect()->to(base_url('auth')); |
|
|
|
|
else { |
|
|
|
|
$model = new Mauth(); |
|
|
|
|
$ldaprdn = 'INTRANET' . "\\" . $username; |
|
|
|
|
$adServer = "ldap://10.254.28.141"; |
|
|
|
|
$ldap = ldap_connect($adServer); |
|
|
|
|
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); |
|
|
|
|
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0); |
|
|
|
|
|
|
|
|
|
$bind = @ldap_bind($ldap, $ldaprdn, $password); |
|
|
|
|
|
|
|
|
|
if ($bind) { |
|
|
|
|
$filter = "(&(objectCategory=person)(objectClass=user)(cn={$username}*) )"; |
|
|
|
|
$ldap_base_dn = "OU=Pegawai DJP,DC=intranet,DC=pajak,DC=go,DC=id"; |
|
|
|
|
$result = ldap_search($ldap, $ldap_base_dn, $filter); |
|
|
|
|
$info = ldap_get_entries($ldap, $result); |
|
|
|
|
for ($i = 0; $i < $info["count"]; $i++) { |
|
|
|
|
if ($info['count'] > 1) break; |
|
|
|
|
$_SESSION['usr'] = $username; |
|
|
|
|
$_SESSION['nama'] = $info[$i]["displayname"][0]; |
|
|
|
|
$_SESSION['nip'] = $info[$i]["employeenumber"][0]; |
|
|
|
|
} |
|
|
|
|
@ldap_close($ldap); |
|
|
|
|
|
|
|
|
|
$data = $model->cekuser($username)->getRowArray(); |
|
|
|
|
$ses_data = [ |
|
|
|
|
'nip' => $data['NIP9'], |
|
|
|
|
'nipp' => $data['NIP18'], |
|
|
|
|
'nama' => $data['NAMA'], |
|
|
|
|
'kppadm' => $data['KPPADM'], |
|
|
|
|
'jabatan' => $data['NAMA_JABATAN'], |
|
|
|
|
'kantor' => $data['NAMA_KANTOR'], |
|
|
|
|
'seksi' => $data['NAMA_UNIT_ES3'], |
|
|
|
|
'isLogin' => true |
|
|
|
|
]; |
|
|
|
|
$session->set($ses_data); |
|
|
|
|
return redirect()->to(base_url('Home')); |
|
|
|
|
} else { |
|
|
|
|
$ldaprdn = 'INTRANET' . "\\" . $username; |
|
|
|
|
$adServer = "ldap://10.254.28.142"; |
|
|
|
|
$ldap = ldap_connect($adServer); |
|
|
|
|
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); |
|
|
|
|
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0); |
|
|
|
|
|
|
|
|
|
$bind = @ldap_bind($ldap, $ldaprdn, $password); |
|
|
|
|
|
|
|
|
|
if ($bind) { |
|
|
|
|
$filter = "(&(objectCategory=person)(objectClass=user)(cn={$username}*) )"; |
|
|
|
|
$ldap_base_dn = "OU=Pegawai DJP,DC=intranet,DC=pajak,DC=go,DC=id"; |
|
|
|
|
$result = ldap_search($ldap, $ldap_base_dn, $filter); |
|
|
|
|
$info = ldap_get_entries($ldap, $result); |
|
|
|
|
for ($i = 0; $i < $info["count"]; $i++) { |
|
|
|
|
if ($info['count'] > 1) break; |
|
|
|
|
$_SESSION['usr'] = $username; |
|
|
|
|
$_SESSION['nama'] = $info[$i]["displayname"][0]; |
|
|
|
|
$_SESSION['nip'] = $info[$i]["employeenumber"][0]; |
|
|
|
|
} |
|
|
|
|
@ldap_close($ldap); |
|
|
|
|
|
|
|
|
|
$data = $model->cekuser($username)->getRowArray(); |
|
|
|
|
$ses_data = [ |
|
|
|
|
'nip' => $data['NIP9'], |
|
|
|
|
'nipp' => $data['NIP18'], |
|
|
|
|
'nama' => $data['NAMA'], |
|
|
|
|
'kppadm' => $data['KPPADM'], |
|
|
|
|
'jabatan' => $data['NAMA_JABATAN'], |
|
|
|
|
'kantor' => $data['NAMA_KANTOR'], |
|
|
|
|
'seksi' => $data['NAMA_UNIT_ES3'], |
|
|
|
|
'isLogin' => true |
|
|
|
|
]; |
|
|
|
|
$session->set($ses_data); |
|
|
|
|
return redirect()->to(base_url('Home')); |
|
|
|
|
|
|
|
|
|
// return true; |
|
|
|
|
} else { |
|
|
|
|
return redirect()->to(base_url('auth')); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function logout() |
|
|
|
|
{ |
|
|
|
|
$session = session(); |
|
|
|
|