if ($miniserv{'userdb'} && !$miniserv{'userdb_addto'}) {
# Adding to group database
- my ($dbh, $proto) = &connect_userdb($miniserv{'userdb'});
+ my ($dbh, $proto, $prefix, $args) =&connect_userdb($miniserv{'userdb'});
&error("Failed to connect to group database : $dbh") if (!ref($dbh));
if ($proto eq "mysql" || $proto eq "postgresql") {
# Add group with SQL
}
}
elsif ($proto eq "ldap") {
- # Add user to LDAP
- # XXX
+ # Add group to LDAP
+ my $dn = "cn=".$group{'name'}.",".$prefix;
+ my @attrs = ( "objectClass", $args->{'groupclass'},
+ "cn", $group{'name'},
+ "webminDesc", $group{'desc'} );
+ my @webminattrs;
+ foreach my $attr (keys %group) {
+ next if ($attr eq "name" || $attr eq "desc" ||
+ $attr eq "modules");
+ my $value = $group{$attr};
+ if ($attr eq "members" || $attr eq "ownmods") {
+ $value = join(" ", @$value);
+ }
+ push(@webminattrs, $attr."=".$value);
+ }
+ if (@webminattrs) {
+ push(@attrs, "webminAttr", \@webminattrs);
+ }
+ if (@{$group{'modules'}}) {
+ push(@attrs, "webminModule", $group{'modules'});
+ }
+ my $rv = $dbh->add($dn, attr => \@attrs);
+ if (!$rv || $rv->code) {
+ &error("Failed to add group to LDAP : ".
+ ($rv ? $rv->error : "Unknown error"));
+ }
}
&disconnect_userdb($miniserv{'userdb'}, $dbh);
$group{'proto'} = $proto;
# Attributes : 1.3.6.1.4.1.9999.4.1.x
# Object classes : 1.3.6.1.4.1.9999.4.2.x
-attributetype ( 1.3.6.1.4.1.9999.4.1.1 NAME 'webminName'
- DESC 'Webmin username'
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{255} SINGLE-VALUE )
-
attributetype ( 1.3.6.1.4.1.9999.4.1.2 NAME 'webminPass'
DESC 'Webmin password'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{255} SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.9999.4.1.3 NAME 'webminAttr'
DESC 'Webmin user attribute name=value format'
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{255} COLLECTIVE )
+ SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{255} )
attributetype ( 1.3.6.1.4.1.9999.4.1.4 NAME 'webminAcl'
DESC 'Webmin user ACL module=name=value format'
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{255} COLLECTIVE )
+ SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{255} )
attributetype ( 1.3.6.1.4.1.9999.4.1.5 NAME 'webminDesc'
DESC 'Webmin group description'
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{255} SINGLE-VALUE )
+ SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{255} )
attributetype ( 1.3.6.1.4.1.9999.4.1.6 NAME 'webminModule'
DESC 'Webmin module name'
- SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{255} COLLECTIVE )
+ SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{255} )
-objectclass ( 1.3.6.1.4.1.9999.4.2.1 NAME 'webminUser' SUP top AUXILIARY
+objectclass ( 1.3.6.1.4.1.9999.4.2.1 NAME 'webminUser' SUP top STRUCTURAL
DESC 'Webmin user account'
- MUST ( webminName $ webminPass )
+ MUST ( cn $ webminPass )
MAY ( webminAttr $ webminAcl $ webminModule ))
-objectclass ( 1.3.6.1.4.1.9999.4.2.2 NAME 'webminGroup' SUP top AUXILIARY
+objectclass ( 1.3.6.1.4.1.9999.4.2.2 NAME 'webminGroup' SUP top STRUCTURAL
DESC 'Webmin group account'
- MUST ( webminName $ webminDesc )
+ MUST ( cn $ webminDesc )
MAY ( webminAttr $ webminAcl $ webminModule ))
my $dbh = $drh->connect($cstr, $user, $pass, { });
$dbh || return &text('sql_emysqlconnect', $drh->errstr);
$dbh->{'AutoCommit'} = 1;
- return wantarray ? ($dbh, $proto) : $dbh;
+ return wantarray ? ($dbh, $proto, $prefix, $args) : $dbh;
}
elsif ($proto eq "postgresql") {
# Connect to PostgreSQL with DBI
my $dbh = $drh->connect($cstr, $user, $pass);
$dbh || return &text('sql_epostgresqlconnect', $drh->errstr);
$dbh->{'AutoCommit'} = 1;
- return wantarray ? ($dbh, $proto) : $dbh;
+ return wantarray ? ($dbh, $proto, $prefix, $args) : $dbh;
}
elsif ($proto eq "ldap") {
# Connect with perl LDAP module
return &text('sql_eldaplogin', $user,
$mesg ? $mesg->error : "Unknown error");
}
- return wantarray ? ($ldap, $proto) : $ldap;
+ return wantarray ? ($ldap, $proto, $prefix, $args) : $ldap;
}
else {
return "Unknown protocol $proto";