{"id":40,"date":"2007-07-13T01:46:23","date_gmt":"2007-07-13T01:46:23","guid":{"rendered":"https:\/\/www.wapshere.com\/missmiis\/?p=40"},"modified":"2023-01-16T08:58:10","modified_gmt":"2023-01-16T08:58:10","slug":"archiving-home-directories","status":"publish","type":"post","link":"https:\/\/www.wapshere.com\/missmiis\/archiving-home-directories","title":{"rendered":"Archiving Home Directories"},"content":{"rendered":"<p>One of the things I love about MIIS is that it can be put to work on any object type you care to name, as long as you can cobble together some sort of automation process.<\/p>\n<p>One such example is a home directory. While needed by the user, it is not part of the user account &#8211; it is a seperate object. It&#8217;s life cycle, while linked to that of the user, may follow a different path. You may be happy to delete a user object, knowing it can be recreated with the same groups and rights &#8211; but you can&#8217;t be so cavalier with data. Business requirements may have the home directory archived, or moved, or re-permissioned to another user. But as long as you can specify these rules, and write some code around them, there&#8217;s no reason why MIIS can&#8217;t manage your user data as effortlessly as your user accounts.<\/p>\n<p>I have already posted about <a href=\"https:\/\/www.wapshere.com\/missmiis\/?p=15\">an extensible MA for user home directory creation<\/a>. I extended this code to make it zip up the home directory after account deletion. For that I needed a VB.NET compatible archiving library. I used <a href=\"http:\/\/www.zbitinc.com\/product.aspx?p=1\" target=\"_blank\" rel=\"noopener noreferrer\">Zbitz<\/a> &#8211; but there&#8217;s plenty to choose from out there.<\/p>\n<h3>Set a Flag<\/h3>\n<p>The first step is to set a flag in the <strong>MVExtension<\/strong> code when I&#8217;ve figured out some sort of action needs to be taken.<\/p>\n<p>In my system I take a two-step process to getting rid of a user. Initially the user account is disabled and a datestamp written into the Description field. At the same time the home directory is zipped to an archive location, though not yet removed. This makes it very easy to restore the account if a mistake was made.<\/p>\n<p>After 90 days, if the account is still disabled, it is deleted along with the home directory.<\/p>\n<p>In the following code snippet, csHomeDir is the CS object representing the home directory. The value numDaysDisabled has been calculated from the datestamp in the user&#8217;s Description field.<\/p>\n<blockquote><p><span style=\"font-size: xx-small;\"><span style=\"color: #0000ff; font-size: xx-small;\">If<\/span> <span style=\"color: #0000ff; font-size: xx-small;\">Not<\/span><span style=\"font-size: xx-small;\"> csHomeDir(&#8220;Status&#8221;).Value.ToLower = &#8220;archived&#8221; <\/span><span style=\"color: #0000ff; font-size: xx-small;\">Then<\/span><br \/>\n<\/span><span style=\"font-size: xx-small;\">\u00a0Utils.TransactionProperties(&#8220;archiveHomedir&#8221;) = <span style=\"color: #0000ff; font-size: xx-small;\">True<\/span><br \/>\n<\/span><span style=\"font-size: xx-small;\"><span style=\"color: #0000ff; font-size: xx-small;\">ElseIf<\/span><span style=\"font-size: xx-small;\"> csHomeDir(&#8220;Status&#8221;).Value.ToLower = &#8220;archived&#8221; <\/span><span style=\"color: #0000ff; font-size: xx-small;\">AndAlso<\/span><span style=\"font-size: xx-small;\"> numDaysDisabled &gt; 90 <\/span><span style=\"color: #0000ff; font-size: xx-small;\">Then<\/span><br \/>\n<\/span><span style=\"font-size: xx-small;\">\u00a0 csHomeDir.Deprovision()<br \/>\n<span style=\"color: #0000ff; font-size: xx-small;\">End<\/span> <span style=\"color: #0000ff; font-size: xx-small;\">If<\/span><\/span><\/p><\/blockquote>\n<h3>Set the Status<\/h3>\n<p>The next thing I need to do is set the Status on the home directory object (as described in <a href=\"https:\/\/www.wapshere.com\/missmiis\/?p=15\">this post<\/a>). This can only be done as a export flow rule, so is a job for the <strong>MAExtension<\/strong> code.<\/p>\n<blockquote><p><span style=\"color: #0000ff; font-size: xx-small;\">Case<\/span><span style=\"font-size: xx-small;\"> &#8220;exportStatus&#8221;<\/span><br \/>\n<span style=\"font-size: xx-small;\"><span style=\"color: #0000ff; font-size: xx-small;\">\u00a0 If<\/span><span style=\"font-size: xx-small;\"> Utils.TransactionProperties(&#8220;archiveHomedir&#8221;) = <\/span><span style=\"color: #0000ff; font-size: xx-small;\">True<\/span> <span style=\"color: #0000ff; font-size: xx-small;\">AndAlso<\/span><span style=\"font-size: xx-small;\"> csentry(&#8220;Status&#8221;).Value = &#8220;active&#8221; <\/span><span style=\"color: #0000ff; font-size: xx-small;\">Then<\/span><\/span><br \/>\n<span style=\"font-size: xx-small;\">\u00a0 csentry(&#8220;Status&#8221;).Value = &#8220;archive pending&#8221;<\/span><br \/>\n<span style=\"font-size: xx-small;\"><span style=\"color: #0000ff; font-size: xx-small;\">\u00a0End<\/span> <span style=\"color: #0000ff; font-size: xx-small;\">If<\/span><\/span><\/p><\/blockquote>\n<h3>Archive the Directory<\/h3>\n<p>Creating the archive is a job for the <strong>CSExtension <\/strong>code. I run the archive and then, if successful, I change the Status to &#8220;archived&#8221;. If the archive was unsuccessful I don&#8217;t make any changes in the SQL table &#8211; the Status remains &#8220;active&#8221; and the whole process will be attempted again.<\/p>\n<blockquote><p><span style=\"color: #0000ff; font-size: xx-small;\">If<\/span><span style=\"font-size: xx-small;\"> csentry(&#8220;Status&#8221;).Value = &#8220;archive pending&#8221; <\/span><span style=\"color: #0000ff; font-size: xx-small;\">Then<\/span><br \/>\n<span style=\"font-size: xx-small;\"><span style=\"color: #0000ff; font-size: xx-small;\">\u00a0 If<\/span><span style=\"font-size: xx-small;\"> <a href=\"https:\/\/www.wapshere.com\/missmiis\/?page_id=41\" target=\"_blank\" rel=\"noopener noreferrer\">ArchiveHomeDir<\/a>(path) =\u00c2\u00a00 <\/span><span style=\"color: #0000ff; font-size: xx-small;\">Then<\/span><\/span><br \/>\n<span style=\"font-size: xx-small;\">\u00a0<a href=\"https:\/\/www.wapshere.com\/missmiis\/?page_id=42\" target=\"_blank\" rel=\"noopener noreferrer\">updateRow<\/a>(path, csentry(&#8220;stringDN&#8221;).Value, csentry(&#8220;Server&#8221;).Value.ToUpper, csentry(&#8220;Volume&#8221;).Value.ToUpper, csentry(&#8220;Folder&#8221;).Value.ToLower, &#8220;archived&#8221;)<\/span><br \/>\n<span style=\"font-size: xx-small;\"><span style=\"color: #0000ff; font-size: xx-small;\">\u00a0 End<\/span> <span style=\"color: #0000ff; font-size: xx-small;\">If<\/span><\/span><br \/>\n<span style=\"font-size: xx-small;\"><span style=\"color: #0000ff; font-size: xx-small;\">End If<\/span><\/span><\/p><\/blockquote>\n<h3>Some Other Comments<\/h3>\n<p>The great thing about this method is that it is very robust. Because the Status field is not changed until the directory has been successfully archived, MIIS will just keep retrying it. If there are a lot of archives, and it&#8217;s holding up other jobs, you can just stop the Export. The next time round MIIS picks up from where it left off.<\/p>\n<p>One slight problem is that I change the Status as part of the Export, and this is a bit of a cheat from an MIIS perspective. Because I&#8217;ve exported &#8220;archive pending&#8221; but then imported either &#8220;archived&#8221; or &#8220;active&#8221; I always get the &#8220;Exported change was not reimported&#8221; warning. But it&#8217;s just a warning, and I was always happy to live with it. Perhaps I&#8217;ll do some further refining at a later date.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the things I love about MIIS is that it can be put to work on any object type you care to name, as long as you can cobble together some sort of automation process. One such example is a home directory. While needed by the user, it is not part of the user&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":[]},"categories":[34,28,7],"tags":[],"class_list":["post-40","post","type-post","status-publish","format-standard","hentry","category-ilm2007","category-miis2003","category-novell"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pkp1o-E","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/40","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/comments?post=40"}],"version-history":[{"count":4,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/40\/revisions"}],"predecessor-version":[{"id":3373,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/40\/revisions\/3373"}],"wp:attachment":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/media?parent=40"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/categories?post=40"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/tags?post=40"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}