ФОРУМ за света на PTC CREO CAD/CAM/CAE софтуерните решения
Здравейте,


office@cadcamcae.bg

www.soft.cadcamcae.bg - Софтуерни решения за машиностроене;

www.forum.cadcamcae.bg - Форум;

www.blog.cadcamcae.bg - Блог;

http://e-shop.cadcamcae.bg - Електронен CAD магазин;

https://www.facebook.com/cad.digest

http://twitter.com/cadcamcae

3D инженерни мишки;

Поздрави
ФОРУМ за света на PTC CREO CAD/CAM/CAE софтуерните решения
Здравейте,


office@cadcamcae.bg

www.soft.cadcamcae.bg - Софтуерни решения за машиностроене;

www.forum.cadcamcae.bg - Форум;

www.blog.cadcamcae.bg - Блог;

http://e-shop.cadcamcae.bg - Електронен CAD магазин;

https://www.facebook.com/cad.digest

http://twitter.com/cadcamcae

3D инженерни мишки;

Поздрави
ФОРУМ за света на PTC CREO CAD/CAM/CAE софтуерните решения
Would you like to react to this message? Create an account in a few clicks or log in to continue.

ФОРУМ за света на PTC CREO CAD/CAM/CAE софтуерните решения

ФОРУМ: Част от проекта на списание CAD ДАЙДЖЕСТ - www.cadcamcae.bg;

CAD ДАЙДЖЕСТ . Едно онлайн издание за CAD/CAM/CAE технологии и машиностроене
 

ИндексИндекс  PortalPortal  ГалерияГалерия  ТърсенеТърсене  Последни снимкиПоследни снимки  Регистрирайте сеРегистрирайте се  ВходВход  
Вход
Потребителско име:
Парола:
Искам да влизам автоматично с всяко посещение: 
:: Забравих си паролата!
Social bookmarking
Social bookmarking reddit      

Bookmark and share the address of ФОРУМ за света на PTC CREO CAD/CAM/CAE софтуерните решения on your social bookmarking website
Новини от twitter.
Latest topics
Търсене
 
 

Display results as :
 
Rechercher Advanced Search
Споделете с приятел.
Споделете форума В,,, с,,,в,,,е,,,т,,,а,,, н,,,а,,, CAD/CAM/CAE/PLM i Вашия форум за социално споделянеBookmark and Share
Навигация.
 Portal
 Индекс
 Потребители
 Профил
 Въпроси/Отговори
 Търсене
Април 2024
НедПонВтоСряЧетПетСъб
 123456
78910111213
14151617181920
21222324252627
282930    
КалендарКалендар

 

 Intralink SQL: Monitoring User Passwords Part 2

Go down 
АвторСъобщение
Admin
Admin
Admin


Male Брой мнения : 797
Местожителство : София, България
Job/hobbies : CAD/CAM специалист
Reputation : 3
Points : 8009
Registration date : 27.03.2008

Intralink SQL: Monitoring User Passwords Part 2 Empty
ПисанеЗаглавие: Intralink SQL: Monitoring User Passwords Part 2   Intralink SQL: Monitoring User Passwords Part 2 Icon_minitimeВто 13 Май - 14:59:06

2008
Intralink SQL: Monitoring User Passwords Part 2

Continued from Intralink SQL: Monitoring User Passwords Part 1

The Trigger:

Finally, we're ready for the trigger itself. It's a bit long and I'll try to explain it in sections. The main three sections define the trigger name and when it is executed, declarations of cursors and variables, and the trigger body.

In this example, 'create or replace' allows us to create a new trigger or replace an existing trigger, without having to first drop the trigger. 'before update of userpassword' indicates that the trigger runs when the userpassword field of pdm.PDM_USER is changing, but not if the email address is changing. We are capturing each row change as it happens using 'for each row'.

In the declare section, two cursors and two variables are defined. The cursors allow looping through (potentially) many values in a table. The cursors here are used for looping through the old passwords less than 180 days old, and all bad passwords. The cursors are limited to rows related to the user undergoing the password change.

In the body of the trigger, virtual tables ":old" and ":new" are often used. As you might suspect, they represent the old values of the table row and the new values of the table row. The trigger can see both and decide upon what action to take.

Much of the trigger below is wrapped in an if-then block. This block determines whether the user being changed is the same as the user doing the change. Only an admin can change another user's password. The 'if' statement figures out whether the user being changed is an admin, and if not, applies the rules of the trigger. If this 'if' statement (and its 'endif') are removed, the trigger applies to all accounts, even admin accounts.

The next if-then block prevents the user from reusing the current password (old password = new password) with 'raise value_error'. This introduces a fictitious error, which stops any further execution. The password change is denied. The user will get a cryptic error message, and there is no way to better inform them why. The error message is semi-obvious for most users that the password did not get changed.

The next two chunks of code open the old password and bad password cursors. The trigger loops through each row in each cursor looking for values in order to 'raise value_error'. The code to process the cursors is nearly identical, even though the cursors are a little different.

The insert statement writes the necessary information to the tracking table. It mostly uses the new table row values, except for the ID which is pulled from the next available value of the sequence. For this trigger, regardless of admin change or not, all successful password changes are recorded to the tracking table.

To create the trigger, copy and paste everything from 'create' down through and including 'run;' into an sqlplus session. 'run' is not actually part if the trigger. It is needed by oracle to compile the trigger. It doesn't actually run the trigger at that time.




create or replace trigger pdm.custom_pwchange_track_trgbefore update of userpassword on pdm.PDM_USERfor each rowdeclarecursor old_passwords(uid int) isselect userpassword from pdm.custom_pwchange_trackwhere userid=uid and modifiedon>=(sysdate-180);old_pw old_passwords%rowtype;cursor bad_passwords(uid int) isselect userpassword from pdm.custom_bad_passwordswhere userid=uid;bad_pw bad_passwords%rowtype;begin---- if a non-admin user is changing their own password, apply rulesif (:new.username = :new.modifiedby AND :new.usertype != 1) then---- If new password is old password, raise exceptionif (:new.userpassword = :old.userpassword) thenraise value_error;end if;---- Read bad passwords, make sure they are not usedopen bad_passwords(:new.userid);loopfetch bad_passwords into bad_pw;exit when bad_passwords%notfound;if bad_pw.userpassword = :new.userpassword thenraise value_error;end if;end loop;close bad_passwords;---- Read old password values for this user, make sure-- they do not reuse a passwordopen old_passwords(:new.userid);loopfetch old_passwords into old_pw;exit when old_passwords%notfound;if old_pw.userpassword = :new.userpassword thenraise value_error;end if;end loop;close old_passwords;--end if;---- Insert new password into tracking tableinsert into pdm.custom_pwchange_track(pwcid, userid, userpassword, modifiedby, modifiedon)values(pdm.custom_pwchange_track_seq.nextval, :new.userid,:new.userpassword, :new.modifiedby, :new.modifiedon);end;.run;When the trigger is in place, if there is some form of error, this command will help (though only a little):


show errors trigger pdm.custom_pwchange_track_trg;
These commands can be used to report information about the trigger:


column OWNER format a8column table_name format a30select OWNER, TRIGGER_NAME, TRIGGER_TYPE,TABLE_OWNER'.'TABLE_NAME as table_name, statusfromall_triggerswhereTRIGGER_NAME like 'custom_PWCHANGE%';
Should the trigger need to be disabled or re-enabled use these commands:


alter trigger pdm.custom_pwchange_track_trg disable;alter trigger pdm.custom_pwchange_track_trg enable;
You may want to purge the old password table of old passwords, without dropping the table altogether. This is not absolutely necessary as the trigger will ignore password more than 180 days old.

To delete old passwords use this command:

delete from pdm.custom_pwchange_track where modifiedon<sysdate-180;
Next time: Using Intralink Scripting to Change Passwords
Върнете се в началото Go down
https://cadcamcae-bg.bulgarianforum.net
 
Intralink SQL: Monitoring User Passwords Part 2
Върнете се в началото 
Страница 1 от 1
 Similar topics
-
» Intralink SQL: Monitoring User Passwords Part 1
» Intralink: Who's Logged In?
» Orphaned Instances in Intralink Commonspace
» Intralink SQL: Changing Revision/Version with Oracle SQL
» Intralink Commonspace Search for Locked Objects

Права за този форум:Не Можете да отговаряте на темите
ФОРУМ за света на PTC CREO CAD/CAM/CAE софтуерните решения :: PTC CREO 4.0: СОФТУЕР ЗА МАШИНОСТРОЕНЕ :: CREO 4.0: Моделиер от висок клас (бивш Pro/ENGINEER Wildfire) :: PDM/PLM - Pro/INTRALINK; Windchill, ProductPoint-
Идете на: