使用TFS,我需要更改版本控制中指定的文件/项的权限。我需要编辑特定用户或所有用户的权限。
例如,我的应用程序将阻止所有用户签入指定的文件。然后,它将允许某个特定用户签入该文件,执行该文件的签入,然后允许所有用户再次签入。
我该怎么做?请提供示例代码。
发布于 2011-06-21 20:29:25
在微软(http://social.msdn.microsoft.com/Forums/en-US/tfsversioncontrol/thread/289fb1f4-4052-41f1-b2bf-f97cd6d9e389/)的宋维奇( Vicky )的指导下,我得出的结论是:
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());
}当CheckInLock为真时,将为签入添加一个拒绝权限。当CheckInLock为false时,将删除签入权限,允许继承指定文件的签入权限。
https://stackoverflow.com/questions/6348184
复制相似问题