EcoStruxure Geo SCADA Expert Forum
Schneider Electric support forum about installation, configuration, integration and troubleshooting of EcoStruxure Geo SCADA Expert (ClearSCADA, ViewX, WebX).
Link copied. Please paste this link to share this article on your social media post.
Posted: 2019-11-06 12:32 PM . Last Modified: 2023-05-03 12:27 AM
>>Message imported from previous forum - Category:Scripts and Tips<<
User: dialvec, originally posted: 2019-02-28 20:35:48 Id:372
Hi.
I wrote this script to check if curent user has admin clearance
Function VerifyUser()
Dim oQuery 'SQL Query to get all users
Dim oQueryRows 'Rows of OQeury result
Dim oMasterGroup 'Object for 'Admin' UserGroup
Dim oCurrentUser 'Object for current user
Dim sCurrentUser 'User requesting station creation
sCurrentUser = Server.Username
'Gets the UserGroup 'Admin' object
Set oQuery = Server.Query("SELECT Fullname FROM CDBUserGroup WHERE Fullname like '%Full'") 'SQL Query
oQueryRows = oQuery.Rows 'Gets the Fullname into a nxn matrix
Set oMasterGroup = Server.FindObject(oQueryRows(0,0)) 'GetS Admin UserGroup object
'Gets fullname of
Set oQuery = Server.Query("SELECT UserGroupNames FROM CDBUser WHERE Name = '" & sCurrentUser & "'") 'SQL Query
oQueryRows = oQUery.Rows 'Contains al the user groups that current user belongs to.
msgbox oQuery.ErrorMessage
Set oCurrentUser = Server.FindObject(oQueryRows(0,0)) 'Gets Current User object
if oCurrentUser.Interface.UserGroupIds = oMasterGroup.Id Then
VerifyUser=1
Else
MsgBox "Error: El usuario actual no tiene permisos de administrador.", vbOKOnly+vbExclamation, "Error"
VerifyUser=0
End if
end Function
But when executing, it gives me the following message:
ExecuteQuery failed: Unknown element
I already reviwed syntaxis and found no mistakes
Any suggestion?
Thank you
Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: 2019-11-06 12:33 PM
>>Responses imported from previous forum
Reply From User: sbeadle, posted: 2019-02-28 21:14:29
Server.FindObject is probably the source of the error. You are passing it a string array, as UserGroupNames is an array. You may want to loop through its members.
Looking at what you are trying to do, why not use the CheckAccess function to see if the user (and therefore group membership) is authorised?
Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: 2019-11-06 12:33 PM
>>Responses imported from previous forum
Reply From User: sbeadle, posted: 2019-02-28 21:14:29
Server.FindObject is probably the source of the error. You are passing it a string array, as UserGroupNames is an array. You may want to loop through its members.
Looking at what you are trying to do, why not use the CheckAccess function to see if the user (and therefore group membership) is authorised?
Link copied. Please paste this link to share this article on your social media post.
Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.