N A M E 
 
         c r e d s m a n   -   i s   a   s i m p l e   P e l   e x t e n s i o n   t o   w o r k   w i t h   ' W i n d o w s   C r e d e n t i a l 
 
         M a n a g e r ' . 
 
 
 
 S Y N O P S I S 
 
                 u s e   s t r i c t ; 
 
                 u s e   w a r n i n g s ; 
 
                 u s e   N e t : : F T P ; 
 
                 u s e   c r e d s m a n   q w ( l o g i n ) ; 
 
 
 
                 #   T h i s   t y p e   o f   f u n c t i o n   i s   n e c e s s a r y   t o   r u n   l o g i n ,   
 
                 #   Y o u   n e e d   t o   h a n d l e   t h e   a c c e s s   o r   c o n n e c t i o n   a n d   E r r o r   m e s s a g e s 
 
 
 
                 s u b   C o n n e c t _ E x a m p l e   { 
 
                         m y   $ c r e d e n t i a l s   =   s h i f t ; 
 
                         #   H e r e   y o u r   c o d e   t o   l o g i n   o r   c o n n e c t   u s i n g   u s e r   a n d   p a s s w o r d 
 
                         i f (   $ c r e d e n t i a l s - > { u s e r }   e q   ' p e p e '   a n d     $ c r e d e n t i a l s - > { p a s s w o r d }   e q   ' p e p e p a s s '   ) { 
 
                                 p r i n t   " T h e   T a r g e t   N a m e   i s :   $ c r e d e n t i a l s - > { t a r g e t } \ n " ; 
 
                                 p r i n t   "     U s e r     :   $ c r e d e n t i a l s - > { u s e r } \ n " ; 
 
                                 p r i n t   "     P a s s     :   $ c r e d e n t i a l s - > { p a s s w o r d } \ n " ; 
 
                                 p r i n t   " A t t e m p t   :   $ c r e d e n t i a l s - > { a t t e m p t }   o f   $ c r e d e n t i a l s - > { l i m i t } \ n " ;   
 
                                 #   R e t u r n   0   -   S u c c e s s 
 
                                 r e t u r n   0 ; 
 
                         } 
 
                         e l s e { 
 
                                 p r i n t   " F a i l \ n " ; 
 
                                 #   R e t u r n   t o   f a i l 
 
                                 r e t u r n   1 ; 
 
                         } 
 
                 } 
 
 
 
                 #   I n   t h i s   E x a m p l e   t h e   p r o g r a m   w i l l   d i e   a t   t h e   a t t e m p t   n u m b e r   1 0 . 
 
 
 
                 d i e   " N o   Z e r o   R e t u r n "   i f   l o g i n (   
 
                         p r o g r a m     = >   ' c r e d s m a n ' ,                     #   T h e   P r e f i x   t o   S t o r e   t h e   c r e d e n t i a l s   i n   w c m   
 
                         t a r g e t       = >   " T e s t " ,                             #   T h e   T a r g e t   t o   v a l i d a t e   u s e r   a n d   p a s s w o r d ,   u s u a l l y   a   s e r v e r 
 
                         s u b r e f       = >   \ & C o n n e c t _ E x a m p l e ,       #   R e f e r e n c e   t o   a   F u n c t i o n   ( h o w   t o   v a l i d a t e   p a s s w o r d ) 
 
                         l i m i t         = >   1 0 ,                                     #   N u m b e r   o f   A t t e m p t s   b e f o r e   t h e   p r o g r a m   F i n i s h 
 
                 ) ; 
 
 
 
                 #   T h i s   E x a m p l e   w i l l   c o n n e c t   t o   F T P   a n d   R e t u r n   t h e   o b j e c t   t o   t h e   f u n c t i o n . 
 
                 #   O p t i o n   u n d e f i n e :       y o u   n e e d   t o   c o m b i n e   w i t h   t h e   i n h e r i t   h a s h   r e f e r e n c e 
 
 
 
                 s u b   C o n n e c t _ F T P   { 
 
                         m y   $ c r e d e n t i a l s   =   s h i f t ; 
 
                         #   H e r e   y o u r   c o d e   t o   l o g i n   o r   c o n n e c t   u s i n g   u s e r   a n d   p a s s w o r d 
 
                         #   T h e   g i v e n   P a r a m e t e r   h a s   t h e   { i n h e r i t }   k e y ,   i f   y o u   p a s s   i t   t h e   f u n c t i o n 
 
                             w i l l   r e t u r n   t h e   i n h e r i t   t o   e v a l u a t e . 
 
                 
 
                         m y   $ f t p   =   N e t : : F T P - > n e w ( " $ c r e d e n t i a l s - > { t a r g e t } " ,   D e b u g   = >   0 ) 
 
                                 o r   d i e   " C a n n o t   c o n n e c t   t o   s o m e . h o s t . n a m e :   $ @ " ; 
 
                 
 
                         m y   $ s t a t u s   =   $ f t p - > l o g i n ( " $ c r e d e n t i a l s - > { u s e r } " , $ c r e d e n t i a l s - > { p a s s w o r d } ) ; 
 
 
 
                         i f (   !   $ s t a t u s   ) { 
 
                                 p r i n t   " A t t e m p t   :   $ c r e d e n t i a l s - > { a t t e m p t }   o f   $ c r e d e n t i a l s - > { l i m i t } \ n " ;   
 
                                 p r i n t   " $ c r e d e n t i a l s - > { u s e r }   c a n n o t   l o g i n   " . $ f t p - > m e s s a g e   . " \ n " ; 
 
                                 r e t u r n   1 ; 
 
                         } 
 
 
 
                         $ { $ c r e d e n t i a l s - > { i n h e r i t } }   =   $ f t p ; 
 
 
 
                         r e t u r n   0 ;   #   S u c c e s s 
 
                 } 
 
       
 
         
 
                 m y   $ f t p   =   C o n n e c t _ F T P (   
 
                         p r o g r a m     = >   ' c r e d s m a n ' ,                     #   T h e   P r e f i x   t o   S t o r e   t h e   c r e d e n t i a l s   i n   w c m   
 
                         t a r g e t       = >   " T e s t " ,                             #   T h e   T a r g e t   t o   v a l i d a t e   u s e r   a n d   p a s s w o r d ,   u s u a l l y   a   s e r v e r 
 
                         s u b r e f       = >   \ & C o n n e c t _ F T P ,               #   R e f e r e n c e   t o   a   F u n c t i o n   ( h o w   t o   v a l i d a t e   p a s s w o r d ) 
 
                         l i m i t         = >   3 ,                                       #   N u m b e r   o f   A t t e m p t s   b e f o r e   t h e   p r o g r a m   F i n i s h 
 
                         u n d e f i n e   = >   1 ,                                       #   T o   u s e   w i t h   i n h e r i t ,   w h e n   y o u   n e e d   t o   p a s s   t h e   o b j e c t . 
 
                 ) ; 
 
         
 
                 d i e   " F a i l   t o   C o n n e c t "   u n l e s s   d e f i n e d   $ f t p ; 
 
 
 
 D E S C R I P T I O N 
 
         C r e d s m a n   ( c r e d e n t i a l   m a n a g e r ) 
 
 
 
         A   s m a l l   l i b r a r y   t h a t   i n t e r a c t s   w i t h   P e r l   a n d   W i n d o w s   C r e d e n t i a l   M a n a g e r . 
 
 
 
         I t   i n c o r p o r a t e s   W i n d o w s   C r e d e n t i a l   G U I .   I t   a l s o   u s e s   a n d   i s   i n t e g r a t e d 
 
         w i t h   t h e   s t a t u s . 
 
 
 
         T h e   C r e d e n t i a l s   w i l l   b e   s t o r e d   w i t h   t h e   F o l l o w i n g   f o r m a t 
 
 
 
                 -   W i n d o w s   C r e d e n t i a l   M a n a g e r   -   G e n e r i c   C r e d e n t i a l s 
 
                 -   f o r m a t : 
 
                 -   * [ ' p r o g r a m   n a m e ' ] ~ [ ' S e r v e r   n a m e   o r   A d d r e s s ' ] * 
 
 
 
     E X P O R T 
 
         l o g i n :   F u n c t i o n   G u i C r e d :   W i n d o w s   G U I   U s e r   a n d   P a s s w o r d   L o g i n . 
 
 
 
 A U T H O R 
 
         R O D A G U   ,   < r o d a g u @ c p a n . o r g > 
 
 
 
 C O P Y R I G H T   A N D   L I C E N S E 
 
         C o p y r i g h t   ( C )   2 0 2 0   b y   R o d r i g o   A g u r t o 
 
 
 
         T h i s   l i b r a r y   i s   f r e e   s o f t w a r e ;   y o u   c a n   r e d i s t r i b u t e   i t   a n d / o r   m o d i f y   i t 
 
         u n d e r   t h e   s a m e   t e r m s   a s   P e r l   i t s e l f ,   e i t h e r   P e r l   v e r s i o n   5 . 3 0 . 0   o r ,   a t 
 
         y o u r   o p t i o n ,   a n y   l a t e r   v e r s i o n   o f   P e r l   5   y o u   m a y   h a v e   a v a i l a b l e . 
 
 
 
 