Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Version control 使用TFS API修改版本控制中文件/项目的权限_Version Control_Tfs_Tfs Sdk - Fatal编程技术网

Version control 使用TFS API修改版本控制中文件/项目的权限

Version control 使用TFS API修改版本控制中文件/项目的权限,version-control,tfs,tfs-sdk,Version Control,Tfs,Tfs Sdk,使用TFS API,我需要更改版本控制中指定文件/项的权限。我需要编辑特定用户或所有用户的权限 例如,我的应用程序将阻止所有用户签入指定的文件。然后,它将允许特定用户签入该文件,执行该文件的签入,然后允许所有用户再次签入 我该怎么做?请提供示例代码 微软的Vicky Song提供了指导(http://social.msdn.microsoft.com/Forums/en-US/tfsversioncontrol/thread/289fb1f4-4052-41f1-b2bf-f97cd6d9e38

使用TFS API,我需要更改版本控制中指定文件/项的权限。我需要编辑特定用户或所有用户的权限

例如,我的应用程序将阻止所有用户签入指定的文件。然后,它将允许特定用户签入该文件,执行该文件的签入,然后允许所有用户再次签入

我该怎么做?请提供示例代码


微软的Vicky Song提供了指导(http://social.msdn.microsoft.com/Forums/en-US/tfsversioncontrol/thread/289fb1f4-4052-41f1-b2bf-f97cd6d9e389/),以下是我的结论:

public void SetCheckInLockForFile(string fileAndPath, string userGroup, bool checkInLock)
{
  // sets of the CheckIn permission for the specified file

  List<SecurityChange> changes = new List<SecurityChange>();
  string[] perm = new string[] { PermissionChange.ItemPermissionCheckin };

  if (checkInLock)
    changes.Add(new PermissionChange(fileAndPath, userGroup, null, perm, null));
  else
    changes.Add(new PermissionChange(fileAndPath, userGroup, null, null, perm));

  SecurityChange[] actualChanges = versionControlServer.SetPermissions(changes.ToArray());

}
public void SetCheckInLockForFile(string fileAndPath、string userGroup、bool checkInLock)
{
//设置指定文件的签入权限
列表更改=新列表();
字符串[]perm=新字符串[]{PermissionChange.ItemPermissionCheckin};
如果(检查锁定)
添加(新权限更改(fileAndPath,userGroup,null,perm,null));
其他的
添加(新权限更改(fileAndPath,userGroup,null,null,perm));
SecurityChange[]actualChanges=versionControlServer.SetPermissions(changes.ToArray());
}

当CheckInLock为true时,将为签入添加拒绝权限。当CheckInLock为false时,签入权限将被删除,从而允许继承指定文件的签入权限。

TFS API可用于完成此任务,但我认为您正在尝试做一些不应该做的事情。你能解释一下你为什么需要这样的东西吗?也许我们可以想出一个替代方案。