Class Credential, wrapper for native CREDENTIAL structure. See CREDENTIAL structure documentation. See Credential Manager documentation.
Inheritance: IDisposable
Ejemplo n.º 1
0
        private static void WriteSingleCredential()
        {
            var credential = new Credential {Target = "Test"};
            credential.Load();

            Console.WriteLine("User name: {0}, Password: {1}", credential.Username, credential.Password);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var credential = new Credential {Target = "Test"};
            credential.Load();

            Console.WriteLine("User name: {0}, Password: {1}", credential.Username, credential.Password);
        }
        public static string GetPassword(Uri targetUri, string username)
        {
            using (Credential creds = new Credential())
            {
                creds.Target = GetTargetString(targetUri, username);
                creds.PersistenceType = PersistenceType.LocalComputer;

                if (creds.Exists())
                {
                    creds.Load();
                    return creds.Password;
                }
                else
                {
                    return null;
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Existses this instance.
        /// </summary>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        /// <exception cref="System.InvalidOperationException">Target must be specified to check existance of a credential.</exception>
        public bool Exists()
        {
            CheckNotDisposed();
            UnmanagedCodePermission.Demand();

            if (string.IsNullOrEmpty(Target))
                throw new InvalidOperationException("Target must be specified to check existance of a credential.");

            using (var existing = new Credential {Target = Target, Type = Type})
            {
                return existing.Load();
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Loads all credentials with filter
 /// </summary>
 /// <param name="filter">Pointer to a null-terminated string that contains the filter for the returned credentials.
 /// Only credentials with a TargetName matching the filter will be returned. The filter specifies a name prefix followed by an asterisk.
 /// For instance, the filter "FRED*" will return all credentials with a TargetName beginning with the string "FRED".
 /// If NULL is specified, all credentials will be returned.</param>
 /// <returns>Credentials collection</returns>
 public static IEnumerable <Credential> GetAllCredentials(string filter)
 {
     return(Credential.LoadAll(filter));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Loads all credentials
 /// </summary>
 /// <returns>Credentials collection</returns>
 public static IEnumerable <Credential> GetAllCredentials()
 {
     return(Credential.LoadAll());
 }