rejetto forum
Software => HFS ~ HTTP File Server => Programmers corner => Topic started by: Roessi on December 17, 2009, 02:47:20 PM
-
hey im kinda new to hfs and wanted to ask if theres an integrated possible to check if a notes key exist in any group the current logged in user is a member of.
i tried to write sth. to check this but it doesnt work. and as i dont really know how to write scripts in hfs i wanted to ask if anyone has an idea whats wrong in the code ;)
{.set|#i|{.count substring|;|{.member of|.}.}.}
{.^#i.}
{.set|groups|;{.member of|.};.}
{.set|curgroup|{.substring|;|;|{.^groups.}|include=0 .}.}
{.set|hasrigth|false.}
{.^curgroup.}
{.while|#i|0.}|
as
{.^curgroup.}
{.if|{.get account|{.^curgroup.}|notes key=test.}|{:
{.set|hasrigth|true.}
hasrigth:{.^hasrigth.}
{.set|#i|.}
.}
{.if not|{.get account|{.^curgroup.}|notes key=test.}|{:
{.set|hasrigth|false.}
{.set|groups|{.cut|{.length|curgroup.}|{.calc|{.length|groups.}-({.length|curgroup.}-2).}|{.^groups.}.}.}
{.set|curgroup|{.substring|;|;|{.^groups.}|include=0 .}.}
hasrigth:{.^hasrigth.}
.}
{.dec|#i.}
.}
hasrigth:{.^hasrigth.}
-
Hi Roessi
You did things not the right way and telling you where are the errors, would be longer than propose a piece of code.
{.set|#accgroups|{.get|accounts|groups.}.}
{.set|#ng|{.count substring|*|{.^#accgroups.}.}.} {.comment| works if groupname stars with * .}
{.for|ii|1|{.^#ng.}|
{:
{.set|tg2|{.substring||;|{.^tg.}.}.}{.set|tg|{.replace|{.^tg2.};||{.^tg.}.}.}
{.if|{.member of|{.^tg2.}|user=%user%.}|
{:
{.set|testval|{.get account|{.^tg2.}|notes key=test.}.}
{.if|{.=|{.^testval.}|allowedvalue.}| {: set or do something :}.}
:}
:}.}
I hope you can understand this code and complete or modify it for your needs.
-
perfect thx very much understood and were able to make a function out of it :) now its working :)
[special:begin]
{.set|getgroupkey|{:
{.set|#accgroups|{.member of|.};%user%.}
{.set|#ng|{.count substring|;|{.^#accgroups.}.}.}
{.dec|#ng.}
{.set|tg|{.^#accgroups.};.}
{.for|ii|-1|{.^#ng.}|
{:
{.set|tg2|{.substring||;|{.^tg.}.}.}
{.set|tg|{.replace|{.^tg2.};||{.^tg.}.}.}
{.if|{.get account|{.^tg2.}|notes key=$1.}}|
{.set|groupkey|{.get account|{.^tg2.}|notes key=$1.}.}
{.^groupkey.}
.}
:}.}
:}.}
{.set|ggk|{:
{.if|
{.and| {.=|{.count substring|false|{.^getgroupkey|$1.}.}|0.} | {.>|{.count substring|true|{.^getgroupkey|$1.}.}|0.} .}|true
|
{.if|{.=|{.get account|%user%|notes key=$1.}|true.}|true.}
.}
:}
.}
finally im able to realize group policies :) thx ;)