Our apologies for the delay, we had some problem with XafariSecurity.
If you use security of Xafari, you can see the creation of a new role and a new user in next code:
Dim strategy = TryCast(SecuritySystem.Instance, SecurityStrategyComplex)
If strategy Is Nothing Then
Return
End If
Dim defaultRole = DirectCast(ObjectSpace.FindObject(strategy.RoleType, New BinaryOperator("Name", "Default")), IDCSecuritySystemRole)
If defaultRole IsNot Nothing Then
Return
End If
defaultRole = DirectCast(ObjectSpace.CreateObject(strategy.RoleType), IDCSecuritySystemRole)
DirectCast(defaultRole, INameSupport).Name = "Default"
Dim userPermissions = ObjectSpace.Xafari().CreateObject(Of IDCSecuritySystemTypePermissionObject)()
userPermissions.TargetType = strategy.UserType
userPermissions.AllowNavigate = True
'
' Access to system user details for current user
'
Dim myDetailsPermission = ObjectSpace.CreateObject(Of IDCSecuritySystemObjectPermissionsObject)()
myDetailsPermission.Criteria = "[Oid] = CurrentUserId()"
myDetailsPermission.AllowNavigate = True
myDetailsPermission.AllowRead = True
userPermissions.ObjectPermissions.Add(myDetailsPermission)
'
' Password access for users
'
Dim ownPasswordPermission = ObjectSpace.CreateObject(Of IDCSecuritySystemMemberPermissionsObject)()
ownPasswordPermission.Members = "ChangePasswordOnFirstLogon;StoredPassword"
ownPasswordPermission.AllowWrite = True
userPermissions.MemberPermissions.Add(ownPasswordPermission)
defaultRole.TypePermissions.Add(userPermissions)
'
' Read role info for current user
'
Dim securityRolePermissions = ObjectSpace.CreateObject(Of IDCSecuritySystemTypePermissionObject)()
securityRolePermissions.TargetType = strategy.RoleType
Dim defaultRolePermission = ObjectSpace.CreateObject(Of IDCSecuritySystemObjectPermissionsObject)()
defaultRolePermission.Criteria = CriteriaOperator.Parse("[Name] = ?", "Default").ToString()
defaultRolePermission.AllowNavigate = True
defaultRolePermission.AllowRead = True
securityRolePermissions.ObjectPermissions.Add(defaultRolePermission)
defaultRole.TypePermissions.Add(securityRolePermissions)
'
' Create user
'
Dim user = ObjectSpace.FindObject(Of IDCSecuritySystemUser)(New BinaryOperator("UserName", "Sam"))
If user Is Nothing Then
user = ObjectSpace.CreateObject(Of IDCSecuritySystemUser)()
user.UserName = "Sam"
user.SetPassword("")
user.DCRoles.Add(defaultRole)
End If
ObjectSpace.CommitChanges()
Thanks for your patience.
Let us know if you need further assistance.