AddUserPartialProfile
Adds a partial profile for the specified user to the zone.
Syntax
IHierarchicalUser AddUserPartialProfile(DirectoryEntry userDE)
IHierarchicalUser AddUserPartialProfile(SearchResult userSR)
IHierarchicalUser AddUserPartialProfile(string userDn)
IHierarchicalUser AddUserPartialProfile(IAdsUser userIAds)
Parameters
Specify one of the following parameters when using this method.
Parameter | Description |
userDE |
The directory entry for the user for which you want a partial profile. |
userSr |
The directory entry for a user specified as a search result. |
userDn |
The user specified as a distinguished name. |
userIads |
The IADs interface to the user. |
Return value
The hierarchical user object that represents the user profile.
Discussion
This method creates a new user profile with values set for the Cims and User properties. If the zone is an SFU zone, then this method also sets a value for the NISDomain property. You can then add other properties to the profile.
The profile is not stored in Active Directory until you call the Commitmethod.
Exceptions
If you pass a null parameter, AddUserPartialProfile throws the exception ArgumentNullException.
Example
The following code sample illustrates using the AddUserPartialProfile method in a script:
... // Create a CIMS object to interact with AD ICims cims = new Cims(); // Note the lack of the cims.connect function. // By default, this application will use the connection to the domain controller // and existing credentials from the computer already logged in. // Get the zone object IHierarchicalZone objZone = cims.GetZoneByPath("cn=" + strZone + "," + strContainerDN) as IHierarchicalZone; if (objZone == null) { Console.WriteLine("Zone " + strZone + " does not exist."); return; } IUser objUser = cims.GetUserByPath(strUser); if (objUser == null) { Console.WriteLine("User " + strUser + " does not exist."); return; } IHierarchicalUser objUserUnixProfile = (IHierarchicalUser) objZone.GetUserUnixProfile(objUser); if (objUserUnixProfile == null) { //New user for the zone objUserUnixProfile = objZone.AddUserPartialProfile(strUser); } IRole objRole = objZone.GetRole(strRole); if (objRole == null) { Console.WriteLine("Role " + strRole + " does not exist."); return; } IRoleAssignment asg = objUserUnixProfile.GetUserRoleAssignment(objRole); if (asg != null) { Console.WriteLine("Assignment already exist."); return; } else { // assigning role to user asg = objUserUnixProfile.AddUserRoleAssignment(); asg.Role = objZone.GetRole(strRole); asg.Commit(); } ...