⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smbldap-useradd

📁 samba-3.0.22.tar.gz 编译smb服务器的源码
💻
📖 第 1 页 / 共 2 页
字号:
				      'uidNumber'   => "$userUidNumber",				      'gidNumber'   => "$userGidNumber",				      'homeDirectory'   => "$userHomeDirectory",				      'loginShell'   => "$config{userLoginShell}",				      'gecos'   => "$config{userGecos}",				      'description'   => "$config{userGecos}",				      'userPassword'   => "{crypt}x"				     ]			    );$add->code && warn "failed to add entry: ", $add->error ;#if ($createGroup) {#    group_add($userName, $userGidNumber);#}group_add_user($userGidNumber, $userName);my $grouplist;# adds to supplementary groupsif (defined($grouplist = $Options{'G'})) {  add_grouplist_user($grouplist, $userName);}# If user was created successfully then we should create his/her home dirif (defined($tmp = $Options{'m'})) {  unless ( $userName =~ /\$$/ ) {    if ( !(-e $userHomeDirectory) ) {      system "mkdir $userHomeDirectory 2>/dev/null";      system "cp -a $config{skeletonDir}/.[a-z,A-Z]* $config{skeletonDir}/* $userHomeDirectory 2>/dev/null";      system "chown -R $userUidNumber:$userGidNumber $userHomeDirectory 2>/dev/null";      if (defined $config{userHomeDirectoryMode}) {	      system "chmod $config{userHomeDirectoryMode} $userHomeDirectory 2>/dev/null";       } else {	      system "chmod 700 $userHomeDirectory 2>/dev/null";       }    }  }}# we start to defined mail adresses if option M or T is given in optionmy @adds;if (@userMailLocal) {  my @mail;  foreach my $m (@userMailLocal) {    my $domain = $config{mailDomain};    if ($m =~ /^(.+)@/) {      push (@mail, $m);      # mailLocalAddress contains only the first part      $m= $1;    } else {      push(@mail, $m.($domain ? '@'.$domain : ''));    }  }  push(@adds, 'mailLocalAddress' => [ @userMailLocal ]);  push(@adds, 'mail' => [ @mail ]);}if (@userMailTo) {  push(@adds, 'mailRoutingAddress' => [ @userMailTo ]);}if (@userMailLocal || @userMailTo) {  push(@adds, 'objectClass' => 'inetLocalMailRecipient');}# Add Samba user infosif (defined($Options{'a'})) {  if (!$config{with_smbpasswd}) {    my $winmagic = 2147483647;    my $valpwdcanchange = 0;    my $valpwdmustchange = $winmagic;    my $valpwdlastset = 0;    my $valacctflags = "[UX]";    if (defined($tmp = $Options{'A'})) {      if ($tmp != 0) {	$valpwdcanchange = "0";      } else {	$valpwdcanchange = "$winmagic";      }    }    if (defined($tmp = $Options{'B'})) {      if ($tmp != 0) {	$valpwdmustchange = "0";	# To force a user to change his password:	# . the attribut sambaPwdLastSet must be != 0	# . the attribut sambaAcctFlags must not match the 'X' flag	$valpwdlastset=$winmagic;	$valacctflags = "[U]";      } else {	$valpwdmustchange = "$winmagic";      }    }    if (defined($tmp = $Options{'H'})) {      $valacctflags = "$tmp";    }    my $modify = $ldap_master->modify ( "uid=$userName,$config{usersdn}",					changes => [						    add => [objectClass => 'sambaSAMAccount'],						    add => [sambaPwdLastSet => "$valpwdlastset"],						    add => [sambaLogonTime => '0'],						    add => [sambaLogoffTime => '2147483647'],						    add => [sambaKickoffTime => '2147483647'],						    add => [sambaPwdCanChange => "$valpwdcanchange"],						    add => [sambaPwdMustChange => "$valpwdmustchange"],						    add => [displayName => "$config{userGecos}"],						    add => [sambaAcctFlags => "$valacctflags"],						    add => [sambaSID => "$config{SID}-$userRid"]						   ]				      );	    $modify->code && die "failed to add entry: ", $modify->error ;  } else {    my $FILE="|smbpasswd -s -a $userName >/dev/null" ;    open (FILE, $FILE) || die "$!\n";    print FILE <<EOF;xxEOF    ;    close FILE;    if ($?) {      print "$0: error adding samba account\n";      exit (10);    }  }				# with_smbpasswd  $tmp = defined($Options{'E'}) ? $Options{'E'} : $config{userScript};  my $valscriptpath = &subst_user($tmp, $userName);  $tmp = defined($Options{'C'}) ? $Options{'C'} : $config{userSmbHome};  my $valsmbhome = &subst_user($tmp, $userName);  my $valhomedrive = defined($Options{'D'}) ? $Options{'D'} : $config{userHomeDrive};  # if the letter is given without the ":" symbol, we add it  $valhomedrive .= ':' if ($valhomedrive && $valhomedrive !~ /:$/);  $tmp = defined($Options{'F'}) ? $Options{'F'} : $config{userProfile};  my $valprofilepath = &subst_user($tmp, $userName);  if ($valhomedrive) {    push(@adds, 'sambaHomeDrive' => $valhomedrive);  }  if ($valsmbhome) {    push(@adds, 'sambaHomePath' => $valsmbhome);  }  if ($valprofilepath) {    push(@adds, 'sambaProfilePath' => $valprofilepath);  }  if ($valscriptpath) {    push(@adds, 'sambaLogonScript' => $valscriptpath);  }  push(@adds, 'sambaPrimaryGroupSID' => $userGroupSID);  push(@adds, 'sambaLMPassword' => "XXX");  push(@adds, 'sambaNTPassword' => "XXX");  my $modify = $ldap_master->modify ( "uid=$userName,$config{usersdn}",				      add => {					      @adds					     }				    );  $modify->code && die "failed to add entry: ", $modify->error ;}$ldap_master->unbind;		# take down sessionif (defined($Options{'P'})) {  exec "$RealBin/smbldap-passwd $userName"}exit 0;########################################=head1 NAMEsmbldap-useradd - Create a new user=head1 SYNOPSISsmbldap-useradd [-o user_ou] [-c comment] [-d home_dir] [-g initial_group] [-G group[,...]] [-m [-k skeleton_dir]] [-s shell] [-u uid [ -o]] [-P] [-A canchange] [-B mustchange] [-C smbhome] [-D homedrive] [-E scriptpath] [-F profilepath] [-H acctflags] login=head1 DESCRIPTIONCreating New Users  The smbldap-useradd command creates a new user account using  the values specified on the  command  line  and  the default  values from the system and from the configuration files (in  /etc/smbldap-tools directory).For Samba users, rid is '2*uidNumber+1000', and sambaPrimaryGroupSID  is '$SID-2*gidNumber+1001', where $SID is the domain SID.  Thus you may want to use :  $ smbldap-useradd -a -g "Domain Admins" -u 500 Administrator to create an domain administrator account (admin rid is 0x1F4 = 500 and grouprid is 0x200 = 512).Without any option, the account created will be an Unix (Posix)  account. The following options may be used to add information:-oThe user's account will be created in the specified organazional unit. It is relative to the user suffix dn ($usersdn) defined in the configuration file.-aThe user will have a Samba account (and Unix).-w Creates an account for a Samba machine (Workstation), so that it can join a sambaDomainName.-i Creates an interdomain trust account (machine Workstation). A password will be asked for the trust account.-c "comment" The new user's comment field (gecos).-d home_dir The new user will be created using home_dir as the value for the user's login directory.  The default is to append the login name      to userHomePrefix (defined in the configuration file) and use that      as the login directory name.-g initial_group  The group name or number of the user's initial login group. The  group  name must exist.  A group number must refer to an already  existing group.  The default group number is defined in the  configuration file (defaultUserGid="513").-G group,[...] A list of supplementary groups which the user is also  a  member of. Each  group is separated to the next by a comma, with no intervening whitespace.  The groups  are  subject  to  the  same restrictions as the group given with the -g option.  The default is for the user to belong only to the initial group.-mThe user's home directory will be created if it does not  exist. The  files  contained in skeletonDir will be copied to the home directory if the -k option is used,  otherwise  the  files  contained  in /etc/skel will be used instead.  Any directories contained in skeletonDir or  /etc/skel  will  be  created  in  the user's  home  directory as well.  The -k option is only valid in conjunction with the -m option.  The default is  to  not  create the directory and to not copy any files.-s shell The name of the user's login shell.  The  default  is  to  leave this  field blank, which causes the system to select the default login shell.-t time Wait <time> seconds before exiting script when adding computer's account. This is useful when Master/PDC and Slaves/BDCs are connected through the internet (replication is not real time)-u uid  The numerical value of  the  user's  ID.   This  value  must  be unique,  unless  the  -o option is used.  The value must be nonnegative.  The default is to use the smallest ID  value  greater than 1000 and greater than every other user.-P ends by invoking smbldap-passwd-A can change password ? 0 if no, 1 if yes-B must change password ? 0 if no, 1 if yes-C sambaHomePath SMB home share, like '\\\\PDC-SRV\\homes'-D sambaHomeDrive letter associated with home share, like 'H:'-E sambaLogonScript relative to the [netlogon] share (DOS script to execute on login, like 'foo.bat'-F sambaProfilePath profile directory, like '\\\\PDC-SRV\\profiles\\foo'-H  sambaAcctFlags  spaces and trailing bracket are ignored (samba account control bits like '[NDHTUMWSLKI]'-M  local mail aliases (multiple addresses are seperated by spaces)-N  canonical name defaults to gecos or username, if gecos not set-S  surname defaults to username-T  mailToAddress (forward address) (multiple addresses are seperated by spaces)-n  do not print banner message=head1 SEE ALSO       useradd(1)=cut#'

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -