Advertisement
Guest User

Untitled

a guest
Feb 11th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. function parseITBLDAPAttribute($x)
  2. {
  3. $z = new StdClass;
  4. $x = explode(';',$x);
  5. for($n=0;$n<count($x);$n++){
  6. $y = explode('=>',$x[$n]);
  7. if(count($y) > 1){
  8. $z->{$y[0]} = isset($y[1]) ? $y[1] : '';
  9. }
  10. }
  11. return $z;
  12. }
  13.  
  14. function access_post(){
  15.  
  16. $username = $this->post('username');
  17. $password = $this->post('password');
  18. $silogin = array(
  19. 'username' => $username,
  20. 'password' => $password
  21. );
  22.  
  23. $wsdl = 'http://nic-ng.itb.ac.id/riset/sson.php?wsdl';
  24. $client = new nusoap_client($wsdl,true);
  25. $cekuser = ($client->call('login',$silogin) == '1' ? TRUE : FALSE);
  26. if ($cekuser) {
  27. $ITB_LDAPAttributes = $client->call('getAllAtribute', array(
  28. 'SID'=> $silogin['username']
  29. ));
  30. $LDAP_parsedData = $this->parseITBLDAPAttribute($ITB_LDAPAttributes);
  31.  
  32. $userdata = array(
  33. 'id_ITB' => $silogin['username'],
  34. 'profile' => array(
  35. 'ai3' => $silogin['username'],
  36. 'nama' => $LDAP_parsedData->itbNamaLengkap,
  37. 'email' => explode(',', $LDAP_parsedData->itbAlamatMail),
  38. 'email_nonITB' => isset($LDAP_parsedData->itbEmailNonITB) ? $LDAP_parsedData->itbEmailNonITB: '',
  39. 'nip' => isset($LDAP_parsedData->itbNIP)? @end(explode(',',$LDAP_parsedData->itbNIP)) : "",
  40. 'nim' => isset($LDAP_parsedData->itbNIM)? @end(explode(',',$LDAP_parsedData->itbNIM)) : "",
  41. 'unit' => $LDAP_parsedData->itbUnity,
  42. 'jenis_civitas' => $LDAP_parsedData->itbStatus
  43. )
  44. );
  45. echo $userdata;
  46. } else{
  47. //$this->response(array('status'=>false,'message'=>'Akun Anda Tidak Ada !'));
  48. echo "Akun Tidak Ada";
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement