首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过活动目录强制登录

通过活动目录强制登录
EN

Stack Overflow用户
提问于 2013-09-02 17:15:20
回答 1查看 930关注 0票数 1

好的,我正在阅读关于集成Perforce用户和Windows用户的文章。

我读过关于触发器的文章,但有些事情我不太清楚.所以如果有人能帮我我会很高兴的。

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

因为据我所知,触发器只是用于身份验证,但是没有办法在Perforce和Active中共享用户的数据库。

谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-26 18:48:25

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

代码语言:javascript
复制
#!/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,FirstName LastName,email@emailaddress.com

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

代码语言:javascript
复制
   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
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18578079

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档