This code works fine within a Kentico website:
var users = UserInfoProvider.GetUsers();
for (int x = 0; x < users.Count(); x++
{
UserInfo currentUser = us
Before you start working with Kentico CMS API from an external application make sure you call the following lines:
CMS.DataEngine.ConnectionHelper.ConnectionString = "your connection string";
CMS.Base.SystemContext.WebApplicationPhysicalPath = Application.StartupPath;
CMS.DataEngine.CMSApplication.Init();
Then, you'll be also able to use UserInfoProvider.GetUsers() object query instead of using DataQuery.Execute()
.