Try OpenEdge Now
skip to main content
Programming Interfaces
Database Administration Entity Interface Reference : IDomain interface : IDomain examples : Adding users to an existing domain
 
Adding users to an existing domain
The following code shows how to use the Users property to add new users to an existing domain. This can also be done when the domain is created. This code shows the usage of the NewUser( ) factory method, passing only the name part of the user ID. The IUser interface Domain property and Tenant property are updated automatically when adding the user to the IDomain user collection through its Users property. For more information, see IUser interface:
define variable domain as IDomain no-undo.
define variable user   as IUser   no-undo.

domain = service:GetDomain("AcmeDomain").

assign
  user = service:NewUser("randersen")
  user:GivenName = "Robert"
  user:SurName = "Andersen".

domain:Users:Add(user).

assign
  user = service:NewUser("mandersen")
  user:GivenName = "Molly"
  user:SurName = "Andersen".
domain:Users:Add(user).

service:UpdateDomain(domain).
See also:
*IAuthenticationSysteminterface
*IDataAdminElementinterface
*IDomainSetinterface
*ITenant interface
*IUserSetinterface