#!/usr/bin/perl # # 14 Dec 2000 Brent Baccala baccala@freesoft.org # # Perl script to add an entry to a NetMeeting LDAP server use Getopt::Std; use Socket; use Net::LDAP qw(:all); use Net::LDAP::Entry; exit unless getopts('h:c:l:e:g:s:vbap'); if ($#ARGV != 1) { print " Usage: $0 [options] cn caddr Adds an entry to a NetMeeting directory server where: cn common name (alias), usually the email address caddr IP or DNS address of the client to be added Options: -h server IP or DNS address of LDAP server (default localhost) -e email email address (no default) -c comment comment (no default) -l location location (no default) -g name given name (no default) -s name surname (no default) -v client is video capable (default audio only) -b business use (default personal) -a adult-only use (default personal) -p permanent entry (default dynamic; only for OpenLDAP servers) "; exit 1; } $cn = $ARGV[0]; $addr = $ARGV[1]; # Convert $addr into a decimal IP address used by NetMeeting $bytestring = inet_aton($addr); if (defined $bytestring) { ($sipaddress) = unpack('V', $bytestring); } else { die "Can't resolve $addr\n"; } $opt_h = "localhost" unless defined $opt_h; $ldap = Net::LDAP->new($opt_h) or die "Can't connect to LDAP server $opt_h\n"; $ldap->bind or die "Can't bind to LDAP server $opt_h\n"; my $entry = Net::LDAP::Entry->new(); $entry->dn("cn=$cn, objectclass=rtperson"); $entry->add(cn => $cn); $entry->add(objectclass => "RTPerson"); $entry->add(sappid => "ms-netmeeting"); $entry->add(sprotid => "h323"); $entry->add(sflags => 1); $entry->add(sipaddress => $sipaddress); $entry->add(givenName => $opt_g) if defined $opt_g; $entry->add(surName => $opt_s) if defined $opt_s; $entry->add(rfc822mailbox => $opt_e) if defined $opt_e; $entry->add(comment => $opt_c) if defined $opt_c; $entry->add(location => $opt_l) if defined $opt_l; $entry->add(timestamp => 0) if defined $opt_p; # Audio capable $entry->add(ilsa32833566 => 1); # Not currently in a call $entry->add(ilsa26214430 => 0); # Video capable if (defined $opt_v) { $entry->add(ilsa32964638 => 1); } else { $entry->add(ilsa32964638 => 0); } # Usage type - personal, business, or adult if (defined $opt_a) { $entry->add(ilsa39321630 => 4); } elsif (defined $opt_b) { $entry->add(ilsa39321630 => 2); } else { $entry->add(ilsa39321630 => 1); } $result = $ldap->add($entry); if ($result->code != LDAP_SUCCESS) { die "Failed to add entry: " . $result->error . "\n"; } print "Successfully added " . $entry->dn() . "\n";