Does velocity not support bit operators?

Hello everyone,

I have been trying to implement an update provisioning policy for AD source and I need to check a bit flag in userAccountControl. This is done via bit operators but when I try using java bit operators, identities go into an error state where those operators are considers Lexical errors. I assume that this means it does not support bit operators. Can anyone confirm that? Is there a workaround?

HI @lukas_ceremeta,

Apache Velocity supports Relational and Logical Operators. You can refer below document for Apache Velocity.

Thanks,
Nikhlesh

Yes I am aware of that page but it does not mention bit operators.

Yes, it does not support bit operator you can try logical operator in your code to satisfy the requirement.

This does not work as the value is a bit field.

Hey @lukas_ceremeta, can you give an example expression of what operation that you’re trying to achieve?

@lukas_ceremeta

As Poorna said, an example would be helpful.

However, I did have one thought. Can you use the value in “AccountFlags” to get the information that you need?

Even something simple like checking userAccountControl for the type of account.
512 - normal account
2048 - interdomain_trust_account

If the userAccountControl is set to 2080, you cannot really check if the account is an interdomain_trust_account or a normal account or even whether its disabled or not.

Hi @lukas_ceremeta , you can try with something like this (testing 2**11):

"value": "#set($int = 0) #set($attr = $int.parseInt($someAttribute)) #set($isBitSet = ($attr / 2048) % 2) #if($isBitSet == 1)true#{else}false#end"

or (testing bit position, 11)

"value": "#set($big = 9223372036854775808) #set($int = 0) #set($attr = $int.parseInt($someAttribute)) $big.valueOf($attr).testBit(11)"
1 Like

Hello,

thank you I will test this. This might actually work.

It did work. At least for now I haven’t seen any issues. Thanks!

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.