Esempio n. 1
0
        /// <summary>
        /// 删除凭据
        /// </summary>
        /// <param name="targetName">IP或者网络地址</param>
        /// <returns>是否删除成功</returns>
        public static bool DeleteCred(string targetName)
        {
            bool flag = false;

            try
            {
                IntPtr intPtr = new IntPtr();
                if (NativeCredMan.WReadCred(targetName, CRED_TYPE.DOMAIN_PASSWORD, 1, out intPtr))
                {
                    flag = NativeCredMan.DeleteCred(targetName.Trim(), CRED_TYPE.DOMAIN_PASSWORD, 0);
                }
                else
                {
                    flag = true;
                }
            }
            catch
            {
                flag = false;
            }

            return(flag);
        }