Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...SQL and SQL Ser...SQL and SQL Ser...SQL Query to Display Users and their Profile by RoleSQL Query to Display Users and their Profile by Role
Previous
 
Next
New Post
7/31/2011 10:34 PM
 
Sebastian Leupold wrote:
 SELECT TOP ... is part of  ANSI SQL and supported by Jet Engine (Access) as well.

 yes ... I stand corrected!
thank you


pmgerholdt
 
New Post
1/21/2012 2:22 PM
 

Thanks for everyone for this great script. It's almost perfect for me. Just need one more tweak.

I would like my users to be able to choose whether their information is visible or not. I was hoping to leverage the Visibility setting that users have access to in their profile editor. They can choose public, members only or admin only. In looking in the UserProfile table, I found the Visibility column and attempted to tweak the script with 

AND P.Visibility < 2

In the LEFT JOIN Select statements. But I got errors when I tried to run the script. Any ideas?

TIA

 
New Post
10/10/2016 12:23 PM
 
Sebastian has this been tested with the newer versions of DotNetNuke, I am currently running version 7.4.2. When trying this under the SQL Host settings of the site I am plagued with errors stating object are not present.

System.Data.SqlClient.SqlException (0x80131904): Cannot find either column "dbo" or the user-defined function or aggregate "dbo.DNN_UserRoleNamesList", or the name is ambiguous.
at System.Data.SqlClient.SqlConnection. (SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection. (SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at DotNetNuke.Data.SqlDataProvider.ExecuteScriptInternal(String connectionString, String script)
ClientConnectionId:d53cfcbf-9125-4cf6-b65f-4e880cbf543d
Error Number:4121,State:1,Class:16

-- =============================================
-- Author: Sebastian Leupold
-- Create date: 2011-04-09
-- Description: returns user data including pro-
-- file properties and role names
-- =============================================
CREATE View DotNetNuke.[UserFullList]
AS
SELECT Top 1000 UP.PortalID, U.UserID, UserName, FirstName, LastName, Displayname, Email,
Unit, Street, City, PostalCode, Region, Country, Cell, Telephone, Telefax, IM, WebSite, [Language], -- << User Profile Properties
dbo.DNN_UserRoleNamesList(UP.PortalID, UP.UserID, Null) Roles
FROM DotNetNuke.[Users] U
INNER JOIN DotNetNuke.[UserPortals] UP ON U.UserID = UP.UserID
-- access each Profile Property:
LEFT JOIN (SELECT PortalID, UserID, PropertyValue Unit FROM DotNetNuke.[ProfilePropertyDefinition] PD INNER JOIN DotNetNuke.[UserProfile] P ON PD.PropertyDefinitionID = P.PropertyDefinitionID WHERE PropertyName = N'Unit' ) P_Unit ON P_Unit.PortalID = UP.PortalID AND P_Unit.UserID = U.UserID
LEFT JOIN (SELECT PortalID, UserID, PropertyValue Street FROM DotNetNuke.[ProfilePropertyDefinition] PD INNER JOIN DotNetNuke.[UserProfile] P ON PD.PropertyDefinitionID = P.PropertyDefinitionID WHERE PropertyName = N'Street' ) P_Street ON P_Street.PortalID = UP.PortalID AND P_Street.UserID = U.UserID
LEFT JOIN (SELECT PortalID, UserID, PropertyValue City FROM DotNetNuke.[ProfilePropertyDefinition] PD INNER JOIN DotNetNuke.[UserProfile] P ON PD.PropertyDefinitionID = P.PropertyDefinitionID WHERE PropertyName = N'City' ) P_City ON P_City.PortalID = UP.PortalID AND P_City.UserID = U.UserID
LEFT JOIN (SELECT PortalID, UserID, PropertyValue PostalCode FROM DotNetNuke.[ProfilePropertyDefinition] PD INNER JOIN DotNetNuke.[UserProfile] P ON PD.PropertyDefinitionID = P.PropertyDefinitionID WHERE PropertyName = N'PostalCode' ) P_ZipCode ON P_ZipCode.PortalID = UP.PortalID AND P_ZipCode.UserID = U.UserID
LEFT JOIN (SELECT PortalID, UserID, PropertyValue Region FROM DotNetNuke.[ProfilePropertyDefinition] PD INNER JOIN DotNetNuke.[UserProfile] P ON PD.PropertyDefinitionID = P.PropertyDefinitionID WHERE PropertyName = N'Region' ) P_Region ON P_Region.PortalID = UP.PortalID AND P_Region.UserID = U.UserID
LEFT JOIN (SELECT PortalID, UserID, PropertyValue Country FROM DotNetNuke.[ProfilePropertyDefinition] PD INNER JOIN DotNetNuke.[UserProfile] P ON PD.PropertyDefinitionID = P.PropertyDefinitionID WHERE PropertyName = N'Country' ) P_Country ON P_Country.PortalID = UP.PortalID AND P_Country.UserID = U.UserID
LEFT JOIN (SELECT PortalID, UserID, PropertyValue Cell FROM DotNetNuke.[ProfilePropertyDefinition] PD INNER JOIN DotNetNuke.[UserProfile] P ON PD.PropertyDefinitionID = P.PropertyDefinitionID WHERE PropertyName = N'Cell' ) P_Cell ON P_Cell.PortalID = UP.PortalID AND P_Cell.UserID = U.UserID
LEFT JOIN (SELECT PortalID, UserID, PropertyValue Telephone FROM DotNetNuke.[ProfilePropertyDefinition] PD INNER JOIN DotNetNuke.[UserProfile] P ON PD.PropertyDefinitionID = P.PropertyDefinitionID WHERE PropertyName = N'Telephone' ) P_Telephone ON P_Telephone.PortalID = UP.PortalID AND P_Telephone.UserID = U.UserID
LEFT JOIN (SELECT PortalID, UserID, PropertyValue Telefax FROM DotNetNuke.[ProfilePropertyDefinition] PD INNER JOIN DotNetNuke.[UserProfile] P ON PD.PropertyDefinitionID = P.PropertyDefinitionID WHERE PropertyName = N'Fax' ) P_Telefax ON P_Telefax.PortalID = UP.PortalID AND P_Telefax.UserID = U.UserID
LEFT JOIN (SELECT PortalID, UserID, PropertyValue IM FROM DotNetNuke.[ProfilePropertyDefinition] PD INNER JOIN DotNetNuke.[UserProfile] P ON PD.PropertyDefinitionID = P.PropertyDefinitionID WHERE PropertyName = N'IM' ) P_IM ON P_IM.PortalID = UP.PortalID AND P_IM.UserID = U.UserID
LEFT JOIN (SELECT PortalID, UserID, PropertyValue Website FROM DotNetNuke.[ProfilePropertyDefinition] PD INNER JOIN DotNetNuke.[UserProfile] P ON PD.PropertyDefinitionID = P.PropertyDefinitionID WHERE PropertyName = N'Website' ) P_Website ON P_Website.PortalID = UP.PortalID AND P_Website.UserID = U.UserID
LEFT JOIN (SELECT PortalID, UserID, PropertyValue [Language] FROM DotNetNuke.[ProfilePropertyDefinition] PD INNER JOIN DotNetNuke.[UserProfile] P ON PD.PropertyDefinitionID = P.PropertyDefinitionID WHERE PropertyName = N'PreferredLocale') P_Language ON P_Language.PortalID = UP.PortalID AND P_Language.UserID = U.UserID
Order by PortalID, LastName, FirstName


 
New Post
10/10/2016 12:59 PM
 
Doug,
did you run all the script - it looks like the first function is missing.
upon first glance, it should still work, though I would write it differently nowadays for better performance.

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
10/10/2016 1:21 PM
 
if you are able to use a stored procedure instead of a view or function, you may use dynamic SQL with a pivot table, as being used in GetAvailableUsersForIndex of my TurboScripts (https://dnnscript.codeplex.com)

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
Previous
 
Next
HomeHomeDevelopment and...Development and...SQL and SQL Ser...SQL and SQL Ser...SQL Query to Display Users and their Profile by RoleSQL Query to Display Users and their Profile by Role


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out