Home - News - Products - Downloads - Manuals - Forum - (trial) License - PriceList - Disclaimer - About
HBWL Program Samples Print

The aug command written in HBWL.

 
   cmd sample_aug(string user,'user',string group, 'group');
   
   int mode=1;     // set the find object search mode 0=must be unique, 1=program dispalys options if not unique
   if (unique) mode:=0; fi;    // unique is a global system variable with the status of the unique flag.
   
   user:=FindObj(mode,user,'User');       // make sure you have the whole name and it is a user-object
   if (lasterror==0)                      // should be 0, otherwise an error 
       group=FindObj(mode,Group,'Group');
       if (lasterror==0)
           if (test)    // check the test/norm mode setting
               write('TEST: ');
           else 
               addtogroup(user,group);
           fi;
               writeln(Format('Add user %s to group %s successfull',user,group));
       else 
           writeln('Error: group does not exist, or not unique, or object is not a group');
       fi;
   else 
       writeln('Error: user does not exist, or not unique, or object is not a user');
   fi;
   
   endcmd;
 

 


 

The ahd command written in HBWL.

 
  cmd shd(string User,"User",string P,"Path",string ?flags="RWECDMF","Flags",string ?force="Y","Force Create");
     
     string obj1,answ;
     bool flag = false;
     string rights = 'RWECDMF';
     int mode=1;   if (unique) mode:=0; fi;
   
     flags=uppercase(flags);
     force=uppercase(force);
   
     bool forceflag = (force=="Y");
     if (flags<>"")  rights=flags; fi;
   
     obj1=FindObj(1,user,"User");
     ifexit (lasterror<>0,"User object not found");
   
     // optional you can add the username to the path
   //  p=p+'\\'+part(obj1,0);
     // you can do any fancy thing you want here for the homedirectory.
   
     p:=expandUNCFilename(P,false);
     
     // check for the path to start with \\, because you have to esc a backslash with a \ you have to give 4 \ characters!
     ifexit( substr(p,1,2)<>'\\\\',  'Homedirectory can not be local!');
   
     // does the direcoty not exist and is the forceflag not set?
     if  (!directoryexists(p) & (!forceflag) )
          repeat
            write('Directory does not exists, create Y/N');
            read(answ);
            answ=uppercase(answ);
          until ((answ<>'') & (answ=="Y") | (answ=='N') );      
          ifexit(answ=="N");
          forceflag:=true;
     fi;
     
     // create directory if it doesn't exist if not in test mode
     if (!directoryexists(p) & forceflag & !test)
        ifexit(!forcedirectories(p),'Creation of directory failed');
     fi; 
   
     // set the trustee, by using the command at if not in test mode
     if (!test)
        command(format("at %s %s %s",obj1,p,rights)); 
     fi;
   
     // we do have a unc path but we need a volume object and the path on the volume
     
     // split the path into server,volume and path;
     
     string server,volume,path;
     parse(p,server,volume,path,true);
   
     // look up the server 
     string serverDN:=FindObj(0,server,'NCP Server');
     ifexit (serverdn=='', "Sorry, can't find server object in the eDirectory");
     
     
     writeln(serverdn);
     
     // now we can find lookup the volume object in the eDirectory
     // search for a volume object with attribute Host Server set to the serverDN 
     // and the Host resource name  set to the volume name
     string volumedn:=search2('[root]','Volume','Host Server',serverdn,'Host Resource Name',volume);
     ifexit(volumedn=='', "Sorry, can't find volume object in the eDirectory");
          
     if (test)
        writeln(Format('TEST: Would add homedirectory %s to %s',p,obj1));
     else
        savepathvalue(obj1,'Home Directory',volumedn,path,0,false);
        writeln(Format('Homedirectory %s added to %s',p,obj1));
     fi;
   endcmd;
 


Copy trustee and Inheritance Mask in HBWL.

 
on hbwlver "1.03.00" do [ -echo "Minimal HBWL version 1.03.00 needed" -stop ]
 
cmd ct(String Source,"Source",String Dest,"Destination");
 
proc walk(String s1, String s2);
 
List dirs = getfiles(s1,true);
item it,trust;
List trustees;
int irm;
 
each (dirs,it)
  write('.');
//writeln(s1,'\\',it.s);
   trustees=listtrustee(s1+'\\'+it.s);
   if (lasterror==0)
       each(trustees,trust)
//        writeln('  Trust=',trust.s,'  ',trust.i);
        addtrustee(s2+'\\'+it.s,trust.s,trust.i);
        if (lasterror<>0) 
           writeln('Add err: ',s2,'\\',it.s,' ',lasterror);
        endif;
      next;
   endif;
   
   irm:=getfileinheritmask(s1+'\\'+it.s) and 0x1FF;
   if (lasterror==0) 
      if (irm<>511)
//         writeln('Mask: ',irm,'  ',lasterror);
         setfileinheritmask(s2+'\\'+it.s,irm);
         if (lasterror<>0)
            cwriteln(clred,"Err set IRM: ",s2,'\\',it.s,' ',lasterror);
         endif;   
      endif;
   else cwriteln(clred,"Err get IRM: ",s1,'\\',it.s,' ',lasterror);
   endif;
   
   walk(s1+'\\'+it.s,s2+'\\'+it.s);
  
next;
endproc;
 
walk(source,dest);
 
endcmd;
 

 
< Prev   Next >
Page created in: 0.18 seconds - © Copyright 2002-2008 HBware.com