Server IP : 195.201.23.43 / Your IP : 3.128.190.205 Web Server : Apache System : Linux webserver2.vercom.be 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64 User : kdecoratie ( 1041) PHP Version : 7.1.33-63+ubuntu20.04.1+deb.sury.org+1 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/share/webmin/ldap-server/ |
Upload File : |
#!/usr/bin/perl # Actually create a new base DN require './ldap-server-lib.pl'; &ReadParse(); &error_setup($text{'create_err'}); $access{'create'} || &error($text{'create_ecannot'}); $ldap = &connect_ldap_db(); ref($ldap) || &error($ldap); # Validate inputs if ($in{'mode'} == 0) { $in{'domain'} =~ /^[a-z0-9\.\-]+$/ || &error($text{'create_edom'}); @p = split(/\./, $in{'domain'}); $dn = join(", ", map { "dc=$_" } @p); } else { $in{'dn'} =~ /^\S+=\S+/ || &error($text{'create_edn'}); $dn = $in{'dn'}; } # Work out class for the DN $schema = $ldap->schema(); @allocs = map { $_->{'name'} } grep { $_->{'structural'} } $schema->all_objectclasses(); @ocs = ( ); foreach my $poc ("top", "domain") { if (&indexof($poc, @allocs) >= 0) { push(@ocs, $poc); } } @ocs || &error(&text('create_eoc')); # Do it, while showing the user &ui_print_unbuffered_header(undef, $text{'create_title'}, ""); # Create the DN print &text('create_doingdn', "<tt>".&html_escape($dn)."</tt>"),"<br>\n"; @attrs = ( "objectClass", \@ocs ); if (&indexof("domain", @ocs) >= 0) { # Domain class needs dc if ($dn =~ /^([^=]+)=([^, ]+)/) { push(@attrs, $1, $2); } } $rv = $ldap->add($dn, attr => \@attrs); if (!$rv || $rv->code) { print &text('create_edoingdn', &ldap_error($rv)),"<p>\n"; } else { print $text{'create_done'},"<p>\n"; $ok = 1; } if ($ok && $in{'example'}) { # Add the example user/alias if ($in{'example'} == 1 || $in{'example'} == 2) { # User $edn = "uid=example, ".$dn; @attrs = ( "cn", "Example user", "sn", "Example user", "uid", "example", "uidNumber", 9999, "gidNumber", 9999, "loginShell", "/bin/sh", "homeDirectory", "/home/example", "objectClass", [ "posixAccount", "person" ], "userPassword", "*LK*" ); if ($in{'example'} == 2) { # With mail push(@attrs, "mail", "example\@example.com"); } } elsif ($in{'example'} == 3) { # Virtuser # XXX not sure about these .. is there any standard? $edn = "cn=example\@example.com, ".$dn; @attrs = ( "mail", "example\@example.com", "mailForwardingAddress", "example\@somewhere.com", "objectClass", [ "top" ] ); } elsif ($in{'example'} == 4) { # Unix group $edn = "cn=example, ".$dn; @attrs = ( "cn", "example", "gidNumber", 9999, "memberUid", "example", "objectClass", [ "posixGroup" ] ); } print &text('create_doingex', "<tt>".&html_escape($edn)."</tt>"),"<br>\n"; $rv = $ldap->add($edn, attr => \@attrs); if (!$rv || $rv->code) { print &text('create_edoingex', &ldap_error($rv)),"<p>\n"; } else { print $text{'create_done'},"<p>\n"; } } if ($ok) { &webmin_log("create", undef, $dn); } &ui_print_footer("", $text{'index_return'});Private