source: companies/serpro/expressoAdmin1_2/inc/class.socomputers.inc.php @ 903

Revision 903, 4.1 KB checked in by niltonneto, 15 years ago (diff)

Importacao inicial do Expresso do Serpro

Line 
1<?php
2        /************************************************************************************\
3        * Expresso Administração                                                                                                     *
4        * by Joao Alfredo Knopik Junior (joao.alfredo@gmail.com, jakjr@celepar.pr.gov.br)        *
5        * -----------------------------------------------------------------------------------*
6        *  This program is free software; you can redistribute it and/or modify it                       *
7        *  under the terms of the GNU General Public License as published by the                         *
8        *  Free Software Foundation; either version 2 of the License, or (at your                        *
9        *  option) any later version.                                                                                                            *
10        \************************************************************************************/
11
12        class socomputers
13        {
14                var $functions;
15               
16                function socomputers()
17                {
18                        $this->functions = CreateObject('expressoAdmin1_2.functions');
19                }
20
21                function write_ldap($dn, $info)
22                {
23                        $connection = $GLOBALS['phpgw']->common->ldapConnect();
24                       
25                        if (ldap_add($connection, $dn, $info))
26                        {
27                                ldap_close($connection);
28                                return true;
29                        }
30                        else
31                        {
32                                echo 'Erro na escrita no LDAP, funcao so->write_ldap';
33                                ldap_close($connection);
34                                return false;
35                        }
36                }
37               
38                function exist_computer_uid($computer_cn)
39                {
40                        $connection = $GLOBALS['phpgw']->common->ldapConnect();
41                        $search = ldap_search($connection, $GLOBALS['phpgw_info']['server']['ldap_context'], "uid=" . $computer_cn . '$');
42                        $result = ldap_get_entries($connection, $search);
43                        if ($result['count'] == 0)
44                                return false;
45                        else
46                                return true;
47                }
48               
49                function get_computer_data($uidnumber, $manager_context)
50                {
51                        $connection = $GLOBALS['phpgw']->common->ldapConnect();
52                        $search = ldap_search($connection, $manager_context, "uidNumber=" . $uidnumber);
53                        $result = ldap_get_entries($connection, $search);
54                       
55                        // Recupera o DN
56                        $computer_data['dn'] = $result[0]['dn'];
57                       
58                        //Recupera o Nome do Computador (CN)
59                        $computer_data['computer_cn'] = $result[0]['cn'][0];
60
61                        //Recupera a flag SAMBA
62                        $computer_data['sambaAcctFlags'] = $result[0]['sambaacctflags'][0];
63                       
64                        // Recupera a descrição
65                        $computer_data['computer_description'] = utf8_decode($result[0]['description'][0]);
66                       
67                        // Recupera o contexto do email_list
68                        $tmp = explode(",", $computer_data['dn']);
69                        for ($i = 1; $i < count($tmp); $i++)
70                                $computer_data['context'] .= $tmp[$i] . ',';
71                        $computer_data['context'] = substr($computer_data['context'],0,(strlen($computer_data['context']) - 1));
72                       
73                        $a_tmp = explode("-", $result[0]['sambasid'][0]);
74                        array_pop($a_tmp);
75                        $computer_data['sambasid'] = implode("-", $a_tmp);
76                       
77                        return $computer_data;
78                }
79               
80                function delete_computer_ldap($dn)
81                {
82                        $connection = $GLOBALS['phpgw']->common->ldapConnect();
83                        $result = ldap_delete($connection, $dn);
84                        ldap_close($connection);
85                        return $result;                         
86                }
87               
88                function rename_ldap($old_dn, $new_rdn, $new_context)
89                {
90                        $connection = $GLOBALS['phpgw']->common->ldapConnect();
91                        $result = ldap_rename($connection, $old_dn, $new_rdn, $new_context, true);
92                        ldap_close($connection);
93                        return $result;
94                }
95               
96                function ldap_add_attribute($ldap_add_attribute, $dn)
97                {
98                        $connection = $GLOBALS['phpgw']->common->ldapConnect();
99                        $result = ldap_mod_add($connection, $dn, $ldap_add_attribute);
100                        ldap_close($connection);
101                        //Escreve no log
102                        $this->functions->write_log($GLOBALS['phpgw']->accounts->data['account_lid'], 'add attributes in ldap in email list', $dn,'','','');                                           
103                        return $result;
104                }
105               
106                function ldap_remove_attribute($ldap_remove_attribute, $dn)
107                {
108                        $connection = $GLOBALS['phpgw']->common->ldapConnect();
109                        $result = ldap_mod_del($connection, $dn, $ldap_remove_attribute);
110                        ldap_close($connection);
111                        //Escreve no log
112                        $this->functions->write_log($GLOBALS['phpgw']->accounts->data['account_lid'], 'remove attributes in ldap in email list', $dn,'','','');                                         
113                        return $result;
114                }
115
116                function ldap_replace_attribute($ldap_replace_attribute, $dn)
117                {
118                        $connection = $GLOBALS['phpgw']->common->ldapConnect();
119                        $result = ldap_mod_replace($connection, $dn, $ldap_replace_attribute);
120                        ldap_close($connection);
121                        return $result;
122                }
123        }
124?>
Note: See TracBrowser for help on using the repository browser.