Authentication in code snippet

This could be a questions that only beginner would ask. I did search for the answer but to no avail.

Is it possible to include authentication method and credentails within the code snippet?
At this point I am interested of seeing NTLM authentication within the code snippet but in the future seeing other authentication methods in code snippet could be very handy. As far this is possible of course.