SNMP community strings permissions

(imported topic written by dmoore21)

In the Windows registry, the SNMP community keys are stored as such:

HKLM\SYSTEM\CurrentControlSet\services\SNMP\Parameters\ValidCommunities\xxxx

Where key xxxx is equal to the community name and the value of the key is equal to the permissions. The value of the key (and it’s corresponding permission) can be one of the following:

1 - None
2 - Notify
4 - Read Only
8 - Read Write
16 - Read Create

I know that I can retrieve the name of the community with the following relevance:

((names of it) of values of it) of key “HKLM\SYSTEM\CurrentControlSet\services\SNMP\Parameters\ValidCommunities” of native registry

I also know that I can retrieve the value of the key with this bit of relevance:

(values of it) of keys “HKLM\SYSTEM\CurrentControlSet\services\SNMP\Parameters\ValidCommunities” of native registry

What I would like to do (and what I am having trouble with) is converting the integer value of the permission to the human readable form. I’ve tried relevance like this:

if exists ((values of it) of key “HKLM\SYSTEM\CurrentControlSet\services\SNMP\Parameters\ValidCommunities” of native registry) then if ((values of it as string = “4”) of key “HKLM\SYSTEM\CurrentControlSet\services\SNMP\Parameters\ValidCommunities” of native registry) then (“Read Only”)

But that didn’t work… Any ideas?

(imported comment written by NoahSalzman)

How about this?

q: (names of it, (if it = 1 then “None” else if it = 2 then “Notify” else if it = 4 then “Read Only” else if it = 8 then “Read Write” else if it = 16 then “Read Create” else “Error”)) of values of key “hklm\system\currentcontrolset\services\snmp\parameters\validcommunities” of registry

A: test-read-only, Read Only

A: test-notify, Notify

A: test-write, Read Write

(imported comment written by dmoore21)

Aha! That work - thanks Noah!