Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
| informatique:printer [04/10/2019 14:25] – ldalbegue | informatique:printer [01/07/2026 09:14] (Version actuelle) – bchicard | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | ==== Annuaire du GNI ==== | + | ~~NOCACHE~~ |
| <PHP> | <PHP> | ||
| - | // mydap version 4 | + | echo ' |
| - | // https:// | + | < |
| - | | + | .pc-wrap { font-family: Arial, sans-serif; font-size: 14px; color: #333; max-width: 720px; } |
| - | global $mydap; | + | .pc-intro { font-size: 13px; color: #666; margin-bottom: 20px; border-left: 3px solid #378ADD; padding: 6px 0 6px 14px; line-height: 1.6; } |
| - | if(isset($mydap)) die('Error, LDAP connection already established' | + | |
| - | + | ||
| - | // Connect to AD | + | |
| - | $mydap = ldap_connect($host, | + | |
| - | + | ||
| - | ldap_set_option($mydap, | + | |
| - | @ldap_bind($mydap, | + | |
| - | + | ||
| - | return true; | + | |
| - | } | + | |
| - | + | ||
| - | function mydap_end() { | + | |
| - | global $mydap; | + | |
| - | if(!isset($mydap)) die(' | + | |
| - | + | ||
| - | // Close existing LDAP connection | + | |
| - | ldap_unbind($mydap); | + | |
| - | } | + | |
| - | + | ||
| - | function mydap_attributes($user_dn, | + | |
| - | global $mydap; | + | |
| - | if(!isset($mydap)) die(' | + | |
| - | if(empty($user_dn)) die(' | + | |
| - | + | ||
| - | // Disable pagination setting, not needed for individual attribute queries | + | |
| - | ldap_control_paged_result($mydap, | + | |
| - | + | ||
| - | // Query user attributes | + | |
| - | $results = (($keep) ? ldap_search($mydap, | + | |
| - | or die(' | + | |
| - | + | ||
| - | $attributes = ldap_get_entries($mydap, | + | |
| - | + | ||
| - | // Return attributes list | + | |
| - | if(isset($attributes[0])) return $attributes[0]; | + | |
| - | else return array(); | + | |
| - | } | + | |
| - | + | ||
| - | function mydap_members($object_dn, | + | |
| - | global $mydap; | + | |
| - | if(!isset($mydap)) die(' | + | |
| - | if(empty($object_dn)) die(' | + | |
| - | + | ||
| - | // Determine class of object we are dealing with | + | |
| - | + | ||
| - | // Groups, use range to overcome LDAP attribute limit | + | |
| - | if($object_class == ' | + | |
| - | $output = array(); | + | |
| - | $range_size = 1500; | + | |
| - | $range_start = 0; | + | |
| - | $range_end = $range_size | + | |
| - | $range_stop = false; | + | |
| - | + | ||
| - | do { | + | |
| - | // Query Group members | + | |
| - | $results = ldap_search($mydap, | + | |
| - | $members = ldap_get_entries($mydap,$results); | + | |
| - | + | ||
| - | $member_base = false; | + | |
| - | + | ||
| - | // Determine array key of the member results | + | |
| - | + | ||
| - | // If array key matches the format of range=$range_start-* we are at the end of the results | + | |
| - | if(isset($members[0][" | + | |
| - | // Set flag to break the do loop | + | |
| - | $range_stop = true; | + | |
| - | // Establish the key of this last segment | + | |
| - | $member_base = $members[0][" | + | |
| - | + | ||
| - | // Otherwise establish the key of this next segment | + | |
| - | } elseif(isset($members[0][" | + | |
| - | $member_base = $members[0][" | + | |
| - | + | ||
| - | if($member_base && isset($member_base[' | + | |
| - | // Remove ' | + | |
| - | array_shift($member_base); | + | |
| - | + | ||
| - | // Append this segment of members to output | + | |
| - | $output = array_merge($output, | + | |
| - | } else $range_stop = true; | + | |
| - | + | ||
| - | if(!$range_stop) { | + | |
| - | // Advance range | + | |
| - | $range_start = $range_end + 1; | + | |
| - | $range_end = $range_end + $range_size; | + | |
| - | } | + | |
| - | } while($range_stop == false); | + | |
| - | + | ||
| - | // Containers and Organizational Units, use pagination to overcome SizeLimit | + | |
| - | } elseif($object_class == ' | + | |
| - | + | ||
| - | $pagesize = 1000; | + | |
| - | $counter = ""; | + | |
| - | do { | + | |
| - | ldap_control_paged_result($mydap, | + | |
| - | + | ||
| - | // Query Container or Organizational Unit members | + | |
| - | $results = ldap_search($mydap, | + | |
| - | $members = ldap_get_entries($mydap, | + | |
| - | + | ||
| - | // Remove ' | + | |
| - | array_shift($members); | + | |
| - | + | ||
| - | // Pull the ' | + | |
| - | foreach($members as $e) $output[] = $e[' | + | |
| - | + | ||
| - | ldap_control_paged_result_response($mydap, | + | |
| - | } while($counter !== null && $counter != "" | + | |
| - | + | ||
| - | // Invalid object_class specified | + | |
| - | } else die(" | + | |
| - | + | ||
| - | // Return alphabetized member list | + | |
| - | sort($output); | + | |
| - | return $output; | + | |
| - | } | + | |
| - | + | ||
| - | // ================================================================================== | + | |
| - | // Example Usage | + | |
| - | // ================================================================================== | + | |
| - | /* | + | |
| - | // Establish connection | + | |
| - | mydap_start( | + | |
| - | ' | + | |
| - | ' | + | |
| - | ' | + | |
| - | 389 // Port (optional) | + | |
| - | ); | + | |
| - | + | ||
| - | // Query users using mydap_members(object_dn, | + | |
| - | // The object_dn parameter should be the distinguishedName of the object | + | |
| - | // The object_class parameter should be ' | + | |
| - | // If left blank object_class will assume Group | + | |
| - | // Ex: the default ' | + | |
| - | // The function returns an array of member distinguishedName' | + | |
| - | $members = mydap_members(' | + | |
| - | if(!$members) die(' | + | |
| - | + | ||
| - | // Now collect attributes for each member pulled | + | |
| - | // Specify user attributes we want to collect, to be used as the keep parameter of mydap_attributes | + | |
| - | $keep = array(' | + | |
| - | + | ||
| - | // Iterate each member to get attributes | + | |
| - | $i = 1; // For counting our output | + | |
| - | foreach($members as $m) { | + | |
| - | // Query a user's attributes using mydap_attributes(member_dn, | + | |
| - | // The member_dn is the step $m of this foreach | + | |
| - | $attr = mydap_attributes($m, | + | |
| - | + | ||
| - | // Each attribute is returned as an array, the first key is [count], [0]+ will contain the actual value(s) | + | |
| - | // You will want to make sure the key exists to account for situations in which the attribute is not returned (has no value) | + | |
| - | $employeeID = isset($attr[' | + | |
| - | $samaccountname = isset($attr[' | + | |
| - | $mail = isset($attr[' | + | |
| - | + | ||
| - | // Do what you will, such as store or display member information | + | |
| - | echo "$i. $samaccountname, | + | |
| - | + | ||
| - | $i++; | + | |
| - | } | + | |
| - | + | ||
| - | // Here you could run another mydap_members() if needed, merge with previous results, etc. | + | |
| - | + | ||
| - | // Close connection | + | |
| - | mydap_end(); | + | |
| - | */ | + | |
| - | // Here you can open a new connection with mydap_connect() if needed, such as to a different AD server | + | |
| - | mydap_start( | + | .pc-hero { display: flex; align-items: |
| - | ' | + | .pc-hero-icon { width: 50px; height: 50px; border-radius: |
| - | ' | + | .pc-hero-icon svg { width: 24px; height: 24px; } |
| - | 'sc-srv-ad.gni.loc', | + | .pc-hero-title { font-size: 17px; font-weight: |
| - | 389 // Port (optional) | + | .pc-hero-sub { font-size: 12px; color: #4B7BAE; } |
| - | ); | + | |
| - | $members = mydap_members(' | + | .pc-block { margin-bottom: |
| - | if(!$members) die(' | + | .pc-block-title { font-size: 13px; font-weight: 700; text-transform: |
| - | echo 'Nbr de Personnes dans l\' | + | .pc-text { font-size: 13px; color: #444; line-height: |
| - | // Now collect attributes for each member pulled | + | .pc-features { display: grid; grid-template-columns: |
| - | // Specify user attributes we want to collect, to be used as the keep parameter of mydap_attributes | + | .pc-feature |
| - | $keep = array(' | + | .pc-feature svg { flex-shrink: |
| - | foreach($members as $m) { | + | .pc-feature-text { font-size: 12.5px; color: #444; line-height: |
| - | // Query a user's attributes using mydap_attributes(member_dn, | + | |
| - | // The member_dn is the step $m of this foreach | + | |
| - | $attr = mydap_attributes($m, | + | |
| - | // Each attribute is returned as an array, the first key is [count], [0]+ will contain the actual value(s) | + | .pc-key-title { font-size: 13px; font-weight: 700; color: #1a2d4a; margin: 6px 0 8px; } |
| - | // You will want to make sure the key exists to account for situations in which the attribute is not returned (has no value) | + | .pc-key-item { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; font-size: 13px; color: #444; line-height: |
| - | + | .pc-key-item svg { flex-shrink: | |
| - | $user[' | + | |
| - | $user[' | + | |
| - | $user[' | + | |
| - | $user[' | + | |
| - | $user[' | + | |
| - | $user[' | + | |
| - | $user[' | + | |
| - | $user[' | + | |
| - | $user[' | + | |
| - | $user[' | + | |
| - | $user[' | + | |
| - | //Photo des users | + | .pc-btn { display: inline-flex; align-items: |
| - | $file = 'https:// | + | .pc-btn: |
| - | $file_headers = @get_headers($file); | + | .pc-btn-primary { background: #185FA5; } |
| - | if($file_headers[0] == ' | + | .pc-btn-secondary |
| - | | + | </ |
| - | } | + | |
| - | else { | + | |
| - | | + | |
| - | } | + | |
| - | $users[$user['login' | + | echo '<div class=" |
| - | } | + | |
| - | // Trie par nom | + | echo '< |
| - | foreach ($users as $key => $row) | + | <div class=" |
| - | { | + | <svg viewBox=" |
| - | $rang[$key] | + | </ |
| - | } | + | <div> |
| - | array_multisort($rang, | + | < |
| + | <div class=" | ||
| + | </ | ||
| + | </ | ||
| - | // Génération du tableau de sortie | + | // ── Pourquoi PaperCut ────────────────────────────────────── |
| - | echo '<br>'; | + | echo '<div class="pc-block">'; |
| - | echo '< | + | echo '<div class="pc-block-title">Pourquoi PaperCut ?</div>'; |
| - | echo '<tr align="center"><td align=" | + | echo '<p class="pc-text">PaperCut est une solution logicielle dédiée à la gestion et au suivi des impressions dans les environnements éducatifs et professionnels. Au Greta Nord-Isère, |
| - | foreach($users as $login | + | echo '< |
| - | { | + | |
| - | echo '<tr align="center">< | + | $features = [ |
| + | [' | ||
| + | ['icon' => '<path d="M3 3v18h18"/><path d="M18 9l-5 5-4-4-3 3"/>', | ||
| + | | ||
| + | | ||
| + | ]; | ||
| + | |||
| + | foreach ($features as $f) { | ||
| + | echo "<div class=' | ||
| + | | ||
| + | | ||
| + | | ||
| } | } | ||
| - | echo '</table>'; | + | echo '</div></ |
| + | |||
| + | // ── Fonctionnalités clés ────────────────────────────────── | ||
| + | echo '< | ||
| + | echo '< | ||
| + | |||
| + | echo '< | ||
| + | <svg viewBox=" | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | echo '< | ||
| + | <svg viewBox=" | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | echo '<a class=" | ||
| + | <svg viewBox=" | ||
| + | Accéder à mon tableau de bord | ||
| + | </ | ||
| + | |||
| + | echo '</ | ||
| + | |||
| + | // ── Besoin d'aide ────────────────────────────────────────── | ||
| + | echo '< | ||
| + | echo '< | ||
| + | echo '<p class=" | ||
| + | |||
| + | echo '<a class=" | ||
| + | <svg viewBox=" | ||
| + | Tutoriel PaperCut — Guide utilisateur | ||
| + | </ | ||
| + | |||
| + | echo '</ | ||
| + | |||
| + | echo '</ | ||
| </ | </ | ||