C++
PHP
Java
Linux & UNIX
ColdFusion
Visual Basic
ActionScript
CGI/Perl
JavaScript
HTML/CSS
Other Languages
Bash
ASP
C
mySQL
Python
C#
Assembly
VB.NET
Scheme
Ruby
Addhost
Password Generator
Switch class for Python
Numbers Guessing Game
Simple SMTP test
Simple Numbers Guessing Game
Fibonacci numbers
Prime numbers
XOR en/decrypter
Factor finder
Authentication Method
Code :
PYTHON - ADDHOST
Code Discription :
Using ldap bindings, add host attribute of local host, to user specified on command line
Right Click And Copy This Code
#!/usr/bin/python import ldap,sys,commands try: l=ldap.open("ldap.mydomain.com"); l.protocol_version = ldap.VERSION3 username = "cn=Manager, dc=mydomain,dc=com" password = "secret" l.simple_bind_s(username, password) g=commands.getoutput("/bin/hostname") dn="uid="+ sys.argv[1] +",ou=accounts,dc=mydomain,dc=com" l.modify_s(dn,[(ldap.MOD_ADD,"host",g)]) except ldap.LDAPError,e: print e
COPYRIGHT © 2007-2008 BY Lib-Code.All rights reserved.
POWERED BY: Lib-Code V1.3