Welcome to the new Schneider Electric Community

It's your place to connect with experts and peers, get continuous support, and share knowledge.

  • Explore the new navigation for even easier access to your community.
  • Bookmark and use our new, easy-to-remember address (community.se.com).
  • Get ready for more content and an improved experience.

Contact SchneiderCommunity.Support@se.com if you have any questions.

Close
Invite a Co-worker
Send a co-worker an invite to the Exchange portal.Just enter their email address and we’ll connect them to register. After joining, they will belong to the same company.
Send Invite Cancel
84650members
353993posts

[Imported] SQL Unknown Element

EcoStruxure Geo SCADA Expert Forum

Find out how SCADA systems and networks, like EcoStruxure Geo SCADA Expert, help industrial organizations maintaining efficiency, processing data for smarter decision making with IoT, RTU and PLC devices.

Solved
sbeadle
Janeway Janeway
Janeway
0 Likes
1
374

[Imported] SQL Unknown Element

>>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


Accepted Solutions
sbeadle
Janeway Janeway
Janeway
0 Likes
0
374

Re: [Imported] SQL Unknown Element

>>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?

See Answer In Context

1 Reply 1
sbeadle
Janeway Janeway
Janeway
0 Likes
0
375

Re: [Imported] SQL Unknown Element

>>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?