Article
Problem
A Forum reader recently asked:
"Are there any available examples for generating a random password as a part of user creation?"
And here's the response from Arno Dorenbusch ...
Solution
Here is the sample code for what you want to do. Note that in the translation, numbers "0123456" are replaced by "abcdefg":
<policy xmlns:random="http://www.novell.com/nxsl/java/java.util.Random"> <rule> <description>generate Password</description> <conditions> <and> <if-class-name mode="nocase" op="equal">User</if-class-name> </and> </conditions> <actions> <do-set-local-variable name="randomNumberGenerator"> <arg-object> <token-xpath expression="random:new()"/> </arg-object> </do-set-local-variable> <do-set-local-variable name="randomNumber"> <arg-string> <token-xpath expression="random:nextLong($randomNumberGenerator)"/> </arg-string> </do-set-local-variable> <do-set-local-variable name="complexPassword"> <arg-string> <token-xpath expression="translate($RandomNumber,'0123456','abcdefg')"/> </arg-string> </do-set-local-variable> <do-set-dest-password> <arg-string> <token-local-variable name="complexPassword"/> </arg-string> </do-set-dest-password> <do-status level="warning"> <arg-string> <token-text xml:space="preserve">Generated Password is: </token-text> <token-local-variable name="complexPassword"/> </arg-string> </do-status> </actions> </rule> </policy>
Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).
It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.
Related Articles
User Comments
- Be the first to comment! To leave a comment you need to Login or Register
- 3198 reads


0