Ask our Experts
Didn't find what you are looking for? Ask our experts!
Support forum for Machine and Motion Control solutions, including Lexium MC12 and robotics, PacDrive, Modicon PLCs and I/Os, EcoStruxure Machine Expert Twin, … - from design, implementation to troubleshooting and more, by Schneider Electric
Search in
Link copied. Please paste this link to share this article on your social media post.
Posted: 2024-04-23 10:31 PM . Last Modified: 2024-11-21 12:53 AM
Codesys offers its own library CmpUserMgr with which you can configure user management from the IEC code.
Online Help:
Example:
VAR
sUser : STRING := 'Administrator';
sPassword: STRING := 'a';
sGroup: STRING := 'NewGroup';
sNewUser: STRING := 'NewUser';
credentials: CmpUserMgr_Implementation.UserMgrCredentials;
stPassword: CmpUserMgr_Interfaces.UserMgrCredentials_Password;
hUser: CmpUserMgr_Implementation.RTS_IEC_HANDLE;
hNewUser: CmpUserMgr_Implementation.RTS_IEC_HANDLE;
hGroup: CmpUserMgr_Implementation.RTS_IEC_HANDLE;
result: CmpUserMgr_Implementation.RTS_IEC_RESULT;
END_VAR
// Login as authorized user
hUser := UserMgrLogin(pszUser:= sUser, pszPassword:= sPassword, pResult:= ADR(result));
// Create a new user group
hGroup := UserMgrGroupAdd(hUser:= hUser, pszGroupName:= sGroup);
// Create a new user and add it to the group
stPassword.pszPassword := ADR('test');
credentials.credential.pwd := stPassword;
credentials.credentialsType := UserMgrCredentials_Type.Password;
hNewUser := UserMgrUserAdd(hUser:= hUser, pszUser:= sNewUser, pCredentials:= credentials);
UserMgrGroupAddUser(hUser:= hUser, pszGroupName:= sGroup, pszUserName:= sNewUser);
UserMgrLogout(hUser := hUser);
Link copied. Please paste this link to share this article on your social media post.
You’ve reached the end of your document
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.