ActiveDirectory Class

MSBuild Extension Pack

ActiveDirectory Class MSBuild Extension Pack Help 4.0.12.0
Valid TaskActions are:

AddUser (Required: User Optional: Domain, FullName, Description, Password, PasswordExpired, PasswordNeverExpires, FirstName, LastName)

AddGroup (Required: Group Optional: Domain, Description, GroupType)

AddGroupToGroup (Required: Parent, Group). Windows Server 2008 only.

AddUserToGroup (Required: User, Group)

CheckUserExists (Required: User Output: Exists)

CheckUserPassword (Required: User, Password Optional: BindingContextOptions, ContextTypeStore, Domain Output: Exists)

CheckGroupExists (Required: Group Output: Exists)

DeleteUser (Required: User)

DeleteGroup (Required: Group)

DeleteUserFromGroup (Required: User, Group)

GetGroupMembers (Required: Group Optional: GetFullMemberName Output: Members)

GetUserPassword (Required: User Optional: BindingContextOptions, ContextTypeStore, Domain, ErrorOnCancelOutput: Password)

GrantPrivilege (Required: User, Privilege Optional: Domain)

RemoveGroupFromGroup (Required: Parent, Group). Windows Server 2008 only.

Remote Execution Support: Yes

Inheritance Hierarchy

SystemObject  Microsoft.Build.UtilitiesTask
    MSBuild.ExtensionPackBaseTask
      MSBuild.ExtensionPack.ComputerActiveDirectory

Namespace: MSBuild.ExtensionPack.Computer
Assembly: MSBuild.ExtensionPack (in MSBuild.ExtensionPack.dll) Version: 4.0.0.0

The ActiveDirectory type exposes the following members.

Constructors

  NameDescription
Public methodActiveDirectory
Top
Properties

  NameDescription
Public propertyBindingContextOptions
Specifies the options that are used for binding to the server. Default is Negotiate
Public propertyContextTypeStore
Specifies the store to use. Supports Machine and Domain. Default is Domain.
Public propertyDescription
Sets the User's or Group's description
Public propertyDomain
Sets the domain to operate against.
Public propertyErrorOnCancel
Set to true to raise an error if the user clicks cancel on GetPassword form.
Public propertyExists
Gets whether the User or Group exists
Public propertyFirstName
Set the User's First name
Public propertyFullName
Sets the User's full name
Public propertyGetFullMemberName
Sets whether to extract the domain name when using GetGroupMembers. Default is false.
Public propertyGroup
Sets the Group name
Public propertyGroupType
Sets the GroupType. For non domains the default is Local. For Domains the default is Global. Supports Global, Local, Universal
Public propertyLastName
Sets the User's Last name
Public propertyMembers
Gets the members of a group
Public propertyParentGroup
Sets the Parent group
Public propertyPassword
Sets the User's password
Public propertyPasswordExpired
Sets the User's password to expired. Default is false
Public propertyPasswordNeverExpires
Sets the User's password to never expire. Default is false
Public propertyPrivilege
The Privilege to grant. See http://msdn.microsoft.com/en-us/library/bb545671(VS.85).aspx
Public propertyUser
Sets the User name. Supports DirectoryPath metadata for AddUserToGroup. Use this to supply different domain users.
Public propertyUserDomain
The domain the user is in. If not set, defaults to Domain.
Top
Examples

<Project ToolsVersion="4.0" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <TPath>$(MSBuildProjectDirectory)\..\MSBuild.ExtensionPack.tasks</TPath>
        <TPath Condition="Exists('$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks')">$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks</TPath>
    </PropertyGroup>
    <Import Project="$(TPath)"/>
    <Target Name="Default">
        <!-- Check a user Exists -->
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="CheckUserExists" User="JudgeJS1">
            <Output TaskParameter="Exists" PropertyName="DoesExist"/>
        </MSBuild.ExtensionPack.Computer.ActiveDirectory>
        <Message Text="JudgeJS1 Exists: $(DoesExist)"/>
        <!-- Add local Users -->
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="AddUser" User="JudgeJS1" Description="Elgnt" Password="123546fdfdRERF$" PasswordNeverExpires="true"/>
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="AddUser" User="JudgeJS2" Description="Elgnt" PasswordNeverExpires="true"/>
        <!-- Grant a user a privilege local Users -->
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="GrantPrivilege" User="JudgeJS1" Privilege="SeServiceLogonRight"/>
        <!-- Check a user Exists -->
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="CheckUserExists" User="JudgeJS1">
            <Output TaskParameter="Exists" PropertyName="DoesExist"/>
        </MSBuild.ExtensionPack.Computer.ActiveDirectory>
        <Message Text="JudgeJS1 Exists: $(DoesExist)"/>
        <!-- Check a Group Exists -->
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="CheckGroupExists" Group="NewGroup1">
            <Output TaskParameter="Exists" PropertyName="DoesExist"/>
        </MSBuild.ExtensionPack.Computer.ActiveDirectory>
        <Message Text="NewGroup1 Exists: $(DoesExist)"/>
        <!-- Add local Groups -->
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="AddGroup" Group="NewGroup1" Description="Elgnt"/>
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="AddGroup" Group="NewGroup2" Description="Elgnt"/>
        <!-- Check a Group Exists -->
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="CheckGroupExists" Group="NewGroup1">
            <Output TaskParameter="Exists" PropertyName="DoesExist"/>
        </MSBuild.ExtensionPack.Computer.ActiveDirectory>
        <Message Text="NewGroup1 Exists: $(DoesExist)"/>
        <!-- Add the users to the Groups -->
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="AddUserToGroup" User="JudgeJS1;JudgeJS2" Group="NewGroup1;NewGroup2"/>
        <!-- To add domain user(s) to a group, prefix name with the user's domain -->
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="AddUserToGroup" User="ADOMAIN\JudgeJS1" Group="Group1"/>
        <!-- Delete Users from Groups -->
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="DeleteUserFromGroup" User="JudgeJS1" Group="NewGroup1;NewGroup2"/>
        <!-- Delete local Users -->
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="DeleteUser" User="JudgeJS1;JudgeJS2"/>
        <!-- Delete local Groups -->
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="DeleteGroup" Group="NewGroup1;NewGroup2"/>
        <!-- Add a remote User -->
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="AddUser" User="JudgeJS1" MachineName="D420-7" Description="Elgnt" Password="123546fdfdRERF$" PasswordNeverExpires="true"/>
        <!-- Add a remote Group -->
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="AddGroup" Group="RemoteGroup1" MachineName="D420-7" Description="na"/>
        <!-- Add a Domain User -->
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="AddUser" User="JudgeJS1" Domain="mydomain" Description="Elgnt" Password="123546fdfdRERF$" PasswordNeverExpires="true"/>
        <!-- Add a Domain Group -->
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="AddGroup" Group="DomainGroup1" Domain="mydomain" Description="na"/>
        <!-- Get a user's password-->
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="GetUserPassword" User="Michael" ContextTypeStore="Machine">
            <Output TaskParameter="Password" PropertyName="Pass"/>
        </MSBuild.ExtensionPack.Computer.ActiveDirectory>
        <Message Text="User Password: $(Pass)"/>
        <!-- Check a user's password-->
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="CheckUserPassword" User="Michael" ContextTypeStore="Machine" Password="$(Pass)">
            <Output TaskParameter="Exists" PropertyName="DoesExist"/>
        </MSBuild.ExtensionPack.Computer.ActiveDirectory>
        <Message Text="User Exists: $(DoesExist)"/>
        <!-- Get Group Members -->
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="GetGroupMembers" Group="Performance Monitor Users;Users">
            <Output TaskParameter="Members" ItemName="Groups"/>
        </MSBuild.ExtensionPack.Computer.ActiveDirectory>
        <Message Text="%(Groups.Identity)"/>
        <!-- Get Group Members including Parent -->
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="GetGroupMembers" GetFullMemberName="true" Group="Performance Monitor Users;Users">
            <Output TaskParameter="Members" ItemName="FullGroups"/>
        </MSBuild.ExtensionPack.Computer.ActiveDirectory>
        <Message Text="FULL %(FullGroups.Identity)"/>
        <!-- Group Group Operations -->
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="AddGroup" Group="NewGroup1" Description="Elgnt" GroupType="Global"/>
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="AddGroup" Group="NewGroup2" Description="Elgnt" GroupType="Global"/>
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="AddGroupToGroup" ParentGroup="NewGroup1" Group="NewGroup2"/>
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="RemoveGroupFromGroup" ParentGroup="NewGroup1" Group="NewGroup2"/>
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="AddGroupToGroup" ParentGroup="NewGroup1" Group="NewGroup2"/>
        <MSBuild.ExtensionPack.Computer.ActiveDirectory TaskAction="AddGroupToGroup" ParentGroup="NewGroup1" Group="NewGroup2"/>
    </Target>
</Project>
See Also

Reference