I am looking for a way to find out if a user has the “Start a Build” permission for a given project.
As of now, I know that the VersionControlServer object can be used to return a string array of the user’s effective permissions within a project. But, when I run the GetEffectivePermissions method on the VersionControlServer, the “Start a Build” and “Administer a Build” permissions are not included in the array that lists the user’s permissions.
I am assuming (incorrectly?) that this is because I am querying a VersionControlServer, which does not control build permissions.
How would I find the user’s effective “build-related” permissions via the TFS 2008 API?
Unfortunately, Team Build does not have a full-blown client object model like Version Control. It’s MUCH better in 2008, but it still lacks its own security API. So you have to step down a level to the more basic webservice interfaces offered server-wide:
Here’s a quick demo in Powershell:
Unfortunately, with this low level API there is no one-stop shopping for “effective permissions.” The Auth service can resolve various ACEs that apply to a user via multiple group membership, as well as a limited form of parent->child inheritance, but I don’t think it knows about the version control hierarchy — only the “common structure” (aka Team Projects -> areas & iterations) hierarchy. Luckily, build permissions are only 1 level deep (always stored @ the Team Project root) so this shouldn’t be an issue in your case.