1

好的,所以我正在阅读有关将 Perforce 用户与 Windows Server 用户集成的内容。

我已经阅读了有关触发器的所有内容,但有些东西对我来说不是很清楚......所以如果有人可以帮助我,我会很高兴。

  • 我还需要在 Perforce 服务器中创建用户/组吗?

因为据我了解,触发器仅用于身份验证,但无法在 Perforce 和 Active Directory 内部的用户之间共享用户数据库。

谢谢。

4

1 回答 1

1

简短的回答是肯定的。但是,一旦 AD 集成启动并运行,您就不需要为它们创建密码。您可以使用 perl 脚本通过命令行批量添加它们,类似于:

#!/usr/bin/perl -w
#------------------------------------------------------------------------------

use strict;
my $InFile;
my $UserID;
my $FullName;
my $Email;
my $CreatedCount = 0;
my $AlreadyExistsCount = 0;
my $FailedCount = 0;
my $Cmd;
my $Out;
my $TmpFile="add_users.user.txt";
my $NoOp = 0;

if (($#ARGV == -1) or ($ARGV[0] =~ /^(-h|-\?|\/h|\/\?)$/i))
{
   print "\nUsage:\n\n\tadd_users.pl VCS_Users_CSV.txt\n\n";
   print "The user list file must contain one-line entries looking like this sample:\n";
   print "\ta200991,Tom Tyler,p4.ttyler\@gmail.com\n\n";
   print "The Perforce environment values for P4PORT and P4USER must be\n";
   print "defined, and the user provided must be a Perforce super users.\n";
   exit 1;
} else {
   $InFile=$ARGV[0];
   die "ERROR: Input file [$InFile] is not readable.\n"
      unless (-r $InFile);
}


$Cmd = "p4 -s info";
$Out = `$Cmd 2>&1`;
if ($Out =~ /info: User name/i) {
   print "\nPerforce server info:\n$Out\n";
} else {
   die "\nERROR: Could not do a 'p4 info'.  Perforce environment is not set.\n";
}

$Cmd = "p4 -s protect -o";
$Out = `$Cmd 2>&1`;
if ($Out =~ /info: Protections:/) {
   print "\nPerforce super user status is verified.\n";
} else {
   die "\nERROR: The current Perforce user is not a super user, and must be.  Aborting.\n";
}

open (INFILE, "<$InFile") or
   die "\nERROR: Failed to open input file [$InFile]: $!\n";

while (<INFILE>) {
   next unless (/.+,.+,.+$/);
   s/\s*$//g;
   $UserID = $_;
   $UserID =~ s/,.*$//g;
   $FullName = $_;
   $FullName =~ s/^.*?,//;
   $FullName =~ s/,.*$//g;
   $Email = $_;
   $Email =~ s/^.*,//;

   unless ($Email =~ /\@/) {
      print "Error: Invalid email addresss [$Email] for user [$UserID].  Skipping.\n";
      $FailedCount++;
      next;
   }

   $Cmd = "p4 -s user -o $UserID";
   $Out = `$Cmd 2>&1`;
   if ($Out =~ /info: Access:/)
   {
      print "User [$UserID] already exists.  Skipping.\n";
      $AlreadyExistsCount++;
   } else {
      print "Creating account [$UserID] for [$FullName] ($Email).\n";
      open (USERFILE, ">$TmpFile") or die "\nERROR: Failed to open temp file [$TmpFile]: $!\n";
      print USERFILE "User:\t$UserID\n\nEmail:\t$Email\n\nFullName:\t$FullName\n\n";
      close (USERFILE);
      $Cmd = "p4 -s user -f -i < $TmpFile";
      if ($NoOp == 0) {
         $Out = `$Cmd 2>&1`;
      } else {
         print "NO-OP: Would run $Cmd\n";
         # Spoof successful user creation
         $Out = "info: User $UserID saved [NO-OP - user creation spoofed].\n";
      }

      if ($Out =~ /info: User .* saved./) {
         print $Out;
         $CreatedCount++;
      } else {
         print $Out;
         print "\nError: Failed to create user [$UserID].  Skipping.\n";
         $FailedCount++;
      }
   }
}

close (INFILE);

print "\nDone.\n\nSummary: $CreatedCount users created, $AlreadyExistsCount already existed, $FailedCount failed.\n\n";

当然,您将需要一个带有适当数据的文本文档,对于这个脚本,它看起来像这样

用户 ID、名字姓氏、email@emailaddress.com

一旦完成,只需从 CMD 运行几行代码:

   C:\Users\a200991> SET P4USER=a200991
   C:\Users\a200991> SET P4PORT=pmperforce01p:1666
   C:\Users\a200991> add_users.pl VCS_Users_CSV.txt > add_users.log 2>&1
   C:\Users\a200991> notepad add_users.log
于 2013-09-26T18:48:25.967 回答