How to create default users

StatusIDPriorityType
Closed38795MajorQuestion
ProfileReply
Kalinda JamesClient

How do you create default users when using xafarisecuritysystem in the moduleupdater.
When I query to see if user already exists in the database using
var user = ObjectSpace.FindObject it returns null even if user already exists in the the database.
I want to create users and permissions ounce on first run only using domain components.
I have set syncmodelwithsecurity to true.

Replies

UserDescriptionPosted On
Kalinda JamesClient

Am evaluating 19.2.6

MariyaVoytovichAgent

Hello!

ObjectSpace.FindObject should return an object. We checked on our demo examples and everything works fine.

In order to fix the issue, we must first reproduce the issue in our labs. We do not have ideas why this error can occur on your machine either.
Could you please provide us with the following info?
1. A small demo project, reproducing the problem;
2. Detailed steps to reproduce the problem.
We want to help you and are looking forward to hearing from you.

Regards,
Mariya
On behalf of Xafari Client Services Team

Kalinda JamesClient

Which demos have creating DC users in code

Kalinda JamesClient

This happens when I use remote idatastore

Kalinda JamesClient

var usersRole2 = ObjectSpace.Xafari().FindObject(new BinaryOperator("Name", "Clerk"));
var usersRole = ObjectSpace.Xafari().FindObject(new BinaryOperator("Name", "Users"));
usersRole2.ChildRoles.Add(usersRole);
IDCSecuritySystemUser user = ObjectSpace.Xafari().FindObject(new BinaryOperator("UserName", "James"));
if (user == null)
{
user = ObjectSpace.Xafari().CreateObject();
user.DCRoles.Add(usersRole);
user.SetPassword("123");
user.UserName = "James";

ObjectSpace.CommitChanges();

}
cant login the second time when using remote idatastore

MariyaVoytovichAgent

Hello!
Please answer the following questions:

1. remote idatastore... do you use WCF service application?
2. What type of authentication do you use XafariAuthentication or others?

Regards,
Mariya
On behalf of Xafari Client Services Team

Kalinda JamesClient

The wcf application is exposing IDatastore contract ,
updater code

public override void SafeUpdateDatabaseAfterUpdateSchema()
{
base.SafeUpdateDatabaseAfterUpdateSchema();
if (CreateUserData())
{
SeedDatabase();
ObjectSpace.CommitChanges();
}

}

private void SeedDatabase()
{
var defaultAccountClass = ObjectSpace.Xafari().CreateObject();
defaultAccountClass.Name = "Default";

}

bool CreateUserData()
{
var usersRole = ObjectSpace.FindObject(new BinaryOperator("Name", XafariSecuritySystem.UsersRoleName));
var principalsRole = ObjectSpace.FindObject(new BinaryOperator("Name", "Principals"));
IDCSecuritySystemUser user = ObjectSpace.FindObject(new BinaryOperator("UserName", "James"));
if (user == null)
{
principalsRole.ChildRoles.Add(usersRole);
user = ObjectSpace.Xafari().CreateObject();
user.DCRoles.Add(principalsRole);
user.SetPassword("123");
user.UserName = "James";
usersRole.ChildRoles.Add(principalsRole);
return true;
}
return false;
}

server code

public class ImsCachedDataStoreService : CachedDataStoreService
{
public static ICachedDataStore DataStore;

static ImsCachedDataStoreService()
{
var connectionString = MSSqlConnectionProvider.GetConnectionString(".\\sqlexpress", "PImsDb99");
var dataStore = XpoDefault.GetConnectionProvider(connectionString, AutoCreateOption.DatabaseAndSchema);
DataStore = new DataCacheRoot(dataStore);
}
public ImsCachedDataStoreService()

: base(DataStore)
{
}
}

I am exposing IDatastore through wcf so yes it is a wcf service but not xaf server

Am using xafarisecuritysystem with syncsecuritywithmodel=true
And domain components

also which email can I use to request a quotation for a custom module

MariyaVoytovichAgent

Hello!

Xafari Client Services is dedicated for helping Xafari customers only.
If you have purchased Xafari subscription please identify yourself.
You can buy Xafari subscription at the page Buy Xafari Framework Subscription
If you have questions about purchasing please contact us via info@galaktika-soft.com

Regards,
Mariya
On behalf of Xafari Client Services Team

× This ticket is closed.

Write US