예제 #1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Initialize new screen
            LogonScreen s = new LogonScreen();

            // Set username
            string SID = string.Empty;
            try
            {
                UserPrincipal user = UserPrincipal.Current;
                s.Username = user.SamAccountName;
                s.DisplayName = user.DisplayName;
                SID = user.Sid.Value;
                s.Context = user.ContextType;
            }
            catch (Exception)
            {
                s.Username = Environment.UserName;
                s.Context = ContextType.Machine;
            }

            // Set background
            string imagePath = GetImagePath(SID) ?? @"C:\Windows\Web\Screen\img100.jpg";
            if (File.Exists(imagePath))
                s.BackgroundImage = Image.FromFile(imagePath);
            else
                s.BackColor = Color.FromArgb(0, 90, 158);

            // Show
            Application.Run(s);
        }
예제 #2
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //string stext = Uri.EscapeDataString("ssss&");
            // Initialize new screen
            LogonScreen s = new LogonScreen();

            // Set username
            string SID = string.Empty;

            try
            {
                PrincipalContext ctx = new PrincipalContext(ContextType.Machine);
                UserPrincipal    user;
                if (args.Length > 0)
                {
                    user = UserPrincipal.FindByIdentity(ctx,
                                                        IdentityType.SamAccountName,
                                                        args[0]);
                }
                else
                {
                    user = UserPrincipal.Current;
                }
                //UserPrincipal user = UserPrincipal.Current;
                s.Username    = user.SamAccountName;
                s.DisplayName = user.DisplayName;
                SID           = user.Sid.Value;
                s.Context     = user.ContextType;
            }
            catch (Exception)
            {
                s.Username = Environment.UserName;
                s.Context  = ContextType.Machine;
            }

            // Set background

/*            string imagePath = GetImagePath(SID) ?? @"C:\Windows\Web\Screen\img100.jpg";
 *          if (File.Exists(imagePath))
 *              s.BackgroundImage = Image.FromFile(imagePath);
 *          else
 *              s.BackColor = Color.FromArgb(0, 90, 158);
 */
            // Show
            Application.Run(s);
        }