PrincipalCollection.Add Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Adds the specified principal to the end of the collection.
Overloads
Add(ComputerPrincipal) |
Adds the specified ComputerPrincipal object to the end of the collection. |
Add(GroupPrincipal) |
Adds the specified GroupPrincipal object to the end of the collection. |
Add(Principal) |
Adds the specified Principal object to the end of the collection. |
Add(UserPrincipal) |
Adds the specified UserPrincipal object to the end of the collection. |
Add(PrincipalContext, IdentityType, String) |
Searches for a Principal object that matches the parameters, and adds it to the end of the collection. |
Remarks
As with Remove and Contains, There are four overloads to this function, but they all do the same thing. The extra overloads are only implemented to improve usability, so that developers using IntelliSense see overloads that take a UserPrincipal, GroupPrincipal, or ComputerPrincipal object. Calling any one of the User, Group, or Computer overloads is exactly equivalent to calling the Principal overload.
Add(ComputerPrincipal)
- Source:
- PrincipalCollection.cs
- Source:
- PrincipalCollection.cs
- Source:
- PrincipalCollection.cs
Adds the specified ComputerPrincipal object to the end of the collection.
public:
void Add(System::DirectoryServices::AccountManagement::ComputerPrincipal ^ computer);
public void Add (System.DirectoryServices.AccountManagement.ComputerPrincipal computer);
[System.Security.SecurityCritical]
public void Add (System.DirectoryServices.AccountManagement.ComputerPrincipal computer);
member this.Add : System.DirectoryServices.AccountManagement.ComputerPrincipal -> unit
[<System.Security.SecurityCritical>]
member this.Add : System.DirectoryServices.AccountManagement.ComputerPrincipal -> unit
Public Sub Add (computer As ComputerPrincipal)
Parameters
- computer
- ComputerPrincipal
A ComputerPrincipal object.
- Attributes
Remarks
This function can throw the following exceptions:
Exception | Description |
---|---|
PrincipalExistsException | computer already exists in the collection. |
Applies to
Add(GroupPrincipal)
- Source:
- PrincipalCollection.cs
- Source:
- PrincipalCollection.cs
- Source:
- PrincipalCollection.cs
Adds the specified GroupPrincipal object to the end of the collection.
public:
void Add(System::DirectoryServices::AccountManagement::GroupPrincipal ^ group);
public void Add (System.DirectoryServices.AccountManagement.GroupPrincipal group);
[System.Security.SecurityCritical]
public void Add (System.DirectoryServices.AccountManagement.GroupPrincipal group);
member this.Add : System.DirectoryServices.AccountManagement.GroupPrincipal -> unit
[<System.Security.SecurityCritical>]
member this.Add : System.DirectoryServices.AccountManagement.GroupPrincipal -> unit
Public Sub Add (group As GroupPrincipal)
Parameters
- group
- GroupPrincipal
A ComputerPrincipal object.
- Attributes
Remarks
This function can throw the following exceptions:
Exception | Description |
---|---|
PrincipalExistsException | group already exists in the collection. |
Applies to
Add(Principal)
- Source:
- PrincipalCollection.cs
- Source:
- PrincipalCollection.cs
- Source:
- PrincipalCollection.cs
Adds the specified Principal object to the end of the collection.
public:
virtual void Add(System::DirectoryServices::AccountManagement::Principal ^ principal);
public void Add (System.DirectoryServices.AccountManagement.Principal principal);
[System.Security.SecurityCritical]
public void Add (System.DirectoryServices.AccountManagement.Principal principal);
abstract member Add : System.DirectoryServices.AccountManagement.Principal -> unit
override this.Add : System.DirectoryServices.AccountManagement.Principal -> unit
[<System.Security.SecurityCritical>]
abstract member Add : System.DirectoryServices.AccountManagement.Principal -> unit
override this.Add : System.DirectoryServices.AccountManagement.Principal -> unit
Public Sub Add (principal As Principal)
Parameters
Implements
- Attributes
Remarks
This function can throw the following exceptions:
Exception | Description |
---|---|
PrincipalExistsException | principal already exists in the collection. |
Applies to
Add(UserPrincipal)
- Source:
- PrincipalCollection.cs
- Source:
- PrincipalCollection.cs
- Source:
- PrincipalCollection.cs
Adds the specified UserPrincipal object to the end of the collection.
public:
void Add(System::DirectoryServices::AccountManagement::UserPrincipal ^ user);
public void Add (System.DirectoryServices.AccountManagement.UserPrincipal user);
[System.Security.SecurityCritical]
public void Add (System.DirectoryServices.AccountManagement.UserPrincipal user);
member this.Add : System.DirectoryServices.AccountManagement.UserPrincipal -> unit
[<System.Security.SecurityCritical>]
member this.Add : System.DirectoryServices.AccountManagement.UserPrincipal -> unit
Public Sub Add (user As UserPrincipal)
Parameters
- user
- UserPrincipal
A UserPrincipal object.
- Attributes
Remarks
This function can throw the following exceptions:
Exception | Description |
---|---|
PrincipalExistsException | user already exists in the collection. |
Applies to
Add(PrincipalContext, IdentityType, String)
- Source:
- PrincipalCollection.cs
- Source:
- PrincipalCollection.cs
- Source:
- PrincipalCollection.cs
Searches for a Principal object that matches the parameters, and adds it to the end of the collection.
public:
void Add(System::DirectoryServices::AccountManagement::PrincipalContext ^ context, System::DirectoryServices::AccountManagement::IdentityType identityType, System::String ^ identityValue);
public void Add (System.DirectoryServices.AccountManagement.PrincipalContext context, System.DirectoryServices.AccountManagement.IdentityType identityType, string identityValue);
[System.Security.SecurityCritical]
public void Add (System.DirectoryServices.AccountManagement.PrincipalContext context, System.DirectoryServices.AccountManagement.IdentityType identityType, string identityValue);
member this.Add : System.DirectoryServices.AccountManagement.PrincipalContext * System.DirectoryServices.AccountManagement.IdentityType * string -> unit
[<System.Security.SecurityCritical>]
member this.Add : System.DirectoryServices.AccountManagement.PrincipalContext * System.DirectoryServices.AccountManagement.IdentityType * string -> unit
Public Sub Add (context As PrincipalContext, identityType As IdentityType, identityValue As String)
Parameters
- context
- PrincipalContext
The PrincipalContext object for the principal to be added to the collection.
- identityType
- IdentityType
An IdentityType object that specifies the format of identityValue
.
- identityValue
- String
A string that identifies the principal, in the format specified by identityType
.
- Attributes
Remarks
This function can throw the following exceptions:
Exception | Description |
---|---|
PrincipalExistsException | The principal matching these parameters already exists in the collection. |
NoMatchingPrincipalException | No principal matching the specified parameters was found. |
MultipleMatchesException | More than one principal matches the specified parameters. |
ArgumentException | identityType is an empty string |
Applies to
.NET