Topics: Developer Forum
Dec 28, 2006 at 2:48 PM

As it seem the PSCredential class is the preferred way to get username and password for a cmdlet. My problem is that the DirectoryEntry.Password supports only String instead of SecureString.

I am not sure where to put this conversion class because it needs the System.Runtime.InteropServices.Marshal class? I use the following methodes: Marshal.SecureStringToBSTR(..) and Marshal.PtrToStringUni(..)
Dec 28, 2006 at 5:17 PM
If you need it in more than one place, then I would create a static helper method in the PscxCmdlet class (you are deriving from that class, right?). If not, then stick it in the one cmdlet class that needs it.
Dec 29, 2006 at 10:06 AM
Ok, I have updated my cmdlets to the PscxCmdlet class and they are now complete.