title: Programmatically create a new Person having an Internal Login
body: <p>I am trying to programmatically create Users with Internal Accounts as part of a testing system.  The following code can not create an InternalLogin because there is not password hash set at object creation time.</p>
  
  <p>Can a person + internal account be created using metadata_* functions ?</p>
  
  <pre><code>data _null_;
    length uri_Person uri_PW uri_IL $256;
    call missing (of uri:);
  
    rc = metadata_getnobj ("Person?@Name='testbot02'", 1, uri_Person); msg=sysmsg();
    put 'NOTE: Get Person, ' rc= uri_Person= / msg;
    if rc = -4 then do;
    rc = metadata_newobj ('Person', uri_Person, 'testbot02'); msg=sysmsg();
    put 'NOTE: New Person, ' rc= uri_Person= / msg;
    end;
  
    rc = metadata_setattr (uri_Person, 'DisplayName', 'Test Bot #2'); msg=sysmsg();
    put 'NOTE: SetAttr, ' rc= / msg;
  
    rc = metadata_newobj ('InternalLogin', uri_IL, 'autobot - IL', 'Foundation', uri_Person, 'InternalLoginInfo'); msg=sysmsg(); 
    put 'NOTE: New InternalLogin, ' rc= / msg;
  run;
  </code></pre>
  
  <p>Logs</p>
  
  <pre><code>NOTE: Get Person, rc=-4 uri_Person=
  
  NOTE: New Person, rc=0 uri_Person=OMSOBJ:Person\A5OJU4RB.AP0000SX
  
  NOTE: SetAttr, rc=0
  
  NOTE: New InternalLogin, rc=-2
  ERROR: AddMetadata of InternalLogin is missing required property PasswordHash.
  NOTE: DATA statement used (Total process time):
        real time           0.02 seconds
        cpu time            0.01 seconds
  </code></pre>
  
  <p>The management console and <code>metabrowse</code> were used to find what objects might need to be created.</p>
  
  <p><a href="https://i.stack.imgur.com/tLPLr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tLPLr.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/8ZsZv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8ZsZv.png" alt="enter image description here"></a></p>
  
  <p>Metabrowse</p>
  
  <p><a href="https://i.stack.imgur.com/Dimgz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Dimgz.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/CW3dO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CW3dO.png" alt="enter image description here"></a></p>