Advertisement
niammuddin

api mikrotik bikin profile dll

Nov 3rd, 2022
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. {
  2. :local postusername "bayan";
  3. :local postprofile "150K";
  4.  
  5. # search profile in RADIUS for save to variable
  6. :do {
  7. :local e ([/user-manager/profile get [find name=$postprofile] name]);
  8. } on-error={:set e "error"};
  9. }
  10. # old user & profile for roolback userprofile
  11. :local oldUser ([/user-manager/user-profile get [find user=$postusername] user]);
  12. :local oldProfile ([/user-manager/user-profile get [find user=$postusername] profile]);
  13.  
  14. # remove profile & session
  15. /user-manager/user-profile remove [find user=$postusername];
  16. /user-manager/session remove [find user=$postusername];
  17.  
  18. # if profile in RADIUS found OR same postProfile DO
  19. :if ($profileRadius = $postprofile) do={
  20. /user-manager/user-profile add user=$postusername profile=$postprofile;
  21. :local newUserProfile ([/user-manager/user-profile get [find user=$postusername] user]);
  22. :put $newUserProfile;
  23.  
  24. } else={
  25.  
  26. # error: roolback userprofile
  27. /user-manager/user-profile add user=$oldUser profile=$oldProfile;
  28. :put "error roolback userprofile";
  29. }
  30. }
  31.  
  32.  
  33.  
  34.  
  35. {
  36. :do {
  37. :local pp ([/user-manager/profile get [find name=100K] name])
  38. } on-error={:put "error"}
  39. :put $pp
  40. }
  41.  
  42.  
  43.  
  44.  
  45.  
  46. {
  47. :local pp "150K";
  48. :do {
  49. :local profilex ([/user-manager/profile get [find name=$pp] name]);
  50. } on-error={:set $profilex "profile_not_found"};
  51. :put $profilex;
  52. }
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60. {
  61. :local var1 "sip1"
  62. :local var2 "sip"
  63. :if (($var1 = "sip1") && ($var2 = "sip")) do={
  64. :put "ok"
  65. } else={
  66. :put "tidak ok"
  67. }
  68. }
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77. # {
  78. # :local olduname ([/user-manager/user-profile get [find user='.$username.'] user]);
  79. # :local oldprof ([/user-manager/user-profile get [find user='.$username.'] profile]);
  80. # /user-manager/user-profile remove [find user='.$username.'];
  81. # /user-manager/session remove [find user='.$username.'];
  82. # /user-manager/user-profile add user='.$username.' profile='.$profile.';
  83. # :local uname ([/user-manager/user-profile get [find user='.$username.'] user]);
  84. # :local prof ([/user-manager/user-profile get [find user='.$username.'] profile]);
  85. # :put ("$uname")
  86. # }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement