Logo Search packages:      
Sourcecode: dacode version File versions  Download package

Ldap::readConfiguration ( OCconfigFilePath = ""  ) 

Reads the LDAP config (Objects definitions)? Parses the file and put it into objectClasses array. Calls echo to display an error message if unable to read file.

Parameters:
string complete path to LDAP classes definitions. private

Definition at line 79 of file ldap.php3.

References count().

Referenced by getAllows(), getObjectClasses(), getRequires(), isAllowed(), isObjectClass(), and isRequired().

      {
            if (empty($OCconfigFilePath))
                  $OCconfigFilePath = $this->OCconfigFilePath;

            if ($cf = fopen($OCconfigFilePath, "rb"))
            {
                  $ctr = 0;
                  while (! feof($cf))
                  {
                        $line = fgets($cf, 1024);
                        // It's blank or ONLY a comment
                        if ((chop($line) == "") || ereg("^[ \t]*#", $line, $regs))
                              continue;
                        if (eregi("[ \t]*objectclass[ \t]+([^#]+)", $line, $regs))
                        {
                              $oc[$ctr] = "";
                              while (chop($line) != "" && ! feof($cf))
                              {
                                    $oc[$ctr] .= $line;
                                    $line = fgets($cf, 10240);
                              }
                        }
                        $ctr++;
                  }
                  for ($ctr = 0; $ctr < count($oc); $ctr++)
                  {
                        $ocdef = split("[ \n\t\r]", $oc[$ctr]);
                        for ($intctr=0, $def = 0; $def < count($ocdef); $def++)
                        {
                              if (chop($ocdef[$def]) != "")
                              {
                                    $intctr++;
                                    switch ($intctr)
                                    {
                                          case 1:
                                                if (strcasecmp($ocdef[$def], "objectclass"))
                                                {
                                                      echo lecho("Error in objectclass ").$ocdef[1].
                                                            lecho(". Expected ")."'objectclass'".lecho(", got ").
                                                            "'".$ocdef[$def]."'<br />";
                                                      exit();
                                                }
                                                break;
                                          case 2:
                                                $ocname = strtolower($ocdef[$def]);
                                                break;
                                          case 3:
                                                if (strcasecmp($ocdef[$def], "requires")
                                                            && strcasecmp($ocdef[$def], "allows"))
                                                {
                                                      echo lecho("Error in objectclass ").$ocdef[1].
                                                            lecho(". Expected ")."'requires'".lecho(" or ")."'allows'".
                                                            lecho(", got ")."'".$ocdef[$def]."'<br />";
                                                      exit();
                                                } else
                                                      $curarray = $ocdef[$def];
                                                $occtr = 0;
                                                break;
                                          default:
                                                if (substr($ocdef[$def], strlen($ocdef[$def])-1, 1) == ",")
                                                {
                                                      // it is _NOT_ the last entry
                                                      $this->objectClasses[$ocname][$curarray][$occtr++] =
                                                            strtolower(substr($ocdef[$def], 0,
                                                            strlen($ocdef[$def])-1));
                                                } else {
                                                      // it _IS_ the last entry
                                                      $this->objectClasses[$ocname][$curarray][$occtr++] =
                                                            strtolower($ocdef[$def]);
                                                      $intctr = 2;
                                                }
                                                break;
                                    }
                              }
                        }
                  }
            } else {
                  $this->error = lecho("Could not open ").$OCconfigFilePath.
                        lecho(" for read.");
                  echo $this->error;
            }
      }


Generated by  Doxygen 1.6.0   Back to index