Unformatted text preview:

PHP ModulesExternal FunctionsReview: PHP 5 ArchitectureExamples of FTP FunctionsLDAPLDAP TermsDistinguished NamesData? Data?LDAP StructureLDAP TreesAn AsideImport and ExportLDIF formatsAdministrationPHP and LDAP02_super_ldap.phpSlide 17Slide 18Slide 1902_super_ldap.php through 06_super_ldap.php03_super_ldap.phpSlide 22Slide 23Slide 2404_super_ldap.php05_super_ldap.php06_super_ldap.phpldap/abhi_ldap.phpOther UsesPowerPoint PresentationSlide 31Local Advantages to LDAPMySQLWhat it isWhy use it?Everything in a tableSlide 37Sample CommandsExamples of MySQL FunctionsOpening a connectionUsing printfSubmitting DataA more selective querySome simple examplesMaterial from the LabOptional LabMore InfoPHP ModulesPHP ModulesLDAP and MySQLExternal FunctionsExternal Functions•In addition to the usual programming functions (arrays, date and time, typing, mathematical, etc), PHP supports a large number of functions linking it to other software (although many of these require special installation):•MySQL. MS SQL, Oracle 8•Shockwave Flash•PDF•IMAP, POP3, NNTP•XML•Many others…•In particular, we'll look at the MySQL and LDAP function setsReview: PHP 5 ArchitectureReview: PHP 5 Architecture•Recall that PHP is modular…image from http://www.zend.com/zend/art/intro.phpExamples of FTP FunctionsExamples of FTP Functionsftp_connect — Opens up an FTP connectionftp_login — Logs in an FTP connectionftp_pwd — Returns the current directory nameftp_cdup — Changes to the parent directoryftp_chdir — Changes directories on a FTP serverftp_mkdir — Creates a directoryftp_rmdir — Removes a directoryftp_nlist — Returns a list of files in the given directory.ftp_get — Downloads a file from the FTP server.ftp_fget — Downloads a file from the FTP server and saves to an open file.ftp_put — Uploads a file to the FTP server.ftp_fput — Uploads from an open file to the FTP server.ftp_size — Returns the size of the given file.ftp_mdtm — Returns the last modified time of the given file.ftp_rename — Renames a file on the ftp server.ftp_delete — Deletes a file on the ftp server.ftp_quit — Closes an FTP connectionLDAPLDAP•Lightweight Directory Access Protocol•Like many "light" services, it's gained weight over time--LDAP is just like XML in this regard•Used to store user data on systems (eg. Active Directory, Open Directory)•Very commonly used for email addressbooks•Also can be used for authentication servicesLDAP TermsLDAP Terms•A directory is a collection of entries•Each entry contains a set of attributes•Attributes have a name, and contain a value•A schema governs the form of attributes, much like a DTD or XML Schema governs an XML documentDistinguished NamesDistinguished Names•Each directory has a root name, the distinguished name•These days that is usually parallel to the IP domain name or the server's IP name, eg:dc=cs,dc=unc,dc=edu(dc stands for domain component--the older system used geographical components)•Entries in the tree also have a distinguished name, but that's relative (RDN), eg:cn=hays,ou=affiliates,dc=cs,dc=unc,dc=edu•This domain based structure allows multiple servers to interact in a hierarchy, much like DNSData? Data?Data? Data?•ldap/abhi_ldap.php•This will show you a dump of my data from ldap.unc.edu (this isn't the only thing up there, but it shows you the kinds of things that are there)•Same basic data, shown a different way:ldap/person_super.phpLDAP StructureLDAP Structure•LDAP uses a tree structure•Leaves can be asymmetrical--that is to say, not all leaves have to be populated, and leaves can contain various numbers of subleaves•This in contrast to the standard table structures--really tho, LDAP sits on top of a DB (usually Berkeley DB) and itself acts as middleware layer•LDAP has a text file format for import/export called ldif (this stuff is all based on the old X500 stuff, so it predates XML)LDAP TreesLDAP Treesimage from http://www.twistedmatrix.com/users/tv/ldap-intro/ldap-intro.htmlAn AsideAn Aside•X.500 is the old school directory system developed by the ITU•This was never adopted in a widespread manner, just to complicated•Developed by telco as a universal directory•There are implementation similarities to•ANS.1 and SNMP•SGML and XML•ATM•The lesson: Prototype early and often and plan on throwing the first one awayImport and ExportImport and Export•LDAP uses a standard text file format for import and export (YAS!)•This is called LDIF, and you'll see it pretty often in conjunction with supporting email clientsLDIF formatsLDIF formatsdn: cn=Barbara Jensen, ou=Product Development, dc=airius, dc=comobjectclass: topobjectclass: personobjectclass: organizationalPersoncn: Barbara Jensencn: Barbara J Jensencn: Babs Jensensn: Jensenuid: bjensentelephonenumber: +1 408 555 1212description: A big sailing fan.dn: cn=Bjorn Jensen, ou=Accounting, dc=airius, dc=comobjectclass: topobjectclass: personobjectclass: organizationalPersoncn: Bjorn Jensensn: Jensentelephonenumber: +1 408 555 1212 from http://www.twistedmatrix.com/users/tv/ldap-intro/ldap-intro.htmlAdministrationAdministration•LDAP has a collection of command line tools for unixes, and a host of browsers for all platforms•There's also a project, phpldapadmin, that is handy for doing ldap administration (and yes, virginia, one could do an ldap and phpldapadmin installation as a project)•There's an analogous product, phpmysqladmin, for MySQLPHP and LDAPPHP and LDAP•Four basic phases•Open a connection to the server:ldap_connect() •Bind to the server (authenticate)ldap_bind() •Do your ldap thing•Close the connectionldap_close()02_super_ldap.php02_super_ldap.php•The basic connection….$ldap_server = "ldap.unc.edu:389";$ldap_server = "ldap.unc.edu:389";……// Connect to ldap server// Connect to ldap server$ldapconn = ldap_connect($ldap_server)$ldapconn = ldap_connect($ldap_server) or die("Could not connect to LDAP server.");or die("Could not connect to LDAP server.");echo 'ldapconn = ' . $ldapconn;echo 'ldapconn = ' . $ldapconn;echo "<br />";echo "<br />";02_super_ldap.php02_super_ldap.php•Binding to ldap// Test to see that we got a connection// Test to see that we got a connectionif ($ldapconn) {if ($ldapconn) { // If the connection requires a password, use this// If the connection requires a password, use this //$ldapbind = ldap_bind($ldapconn, $ldaprdn, //$ldapbind = ldap_bind($ldapconn, $ldaprdn,


View Full Document

UNC-Chapel Hill INLS 672 - PHP Modules - LDAP and MySQL

Download PHP Modules - LDAP and MySQL
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view PHP Modules - LDAP and MySQL and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view PHP Modules - LDAP and MySQL 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?