Greetings to all!
The user runs the program on his computer, passes domain authentication.
All his actions should be logged. At the function call log stage, an exception is thrown:
System.DirectoryServices.Protocols.DirectoryOperationException: Сервер не может обработать запросы каталогов. в System.DirectoryServices.Protocols.ErrorChecking.CheckAndSetLdapError(Int32 error) в System.DirectoryServices.Protocols.LdapSessionOptions.FastConcurrentBind() в System.DirectoryServices.AccountManagement.CredentialValidator.BindLdap(NetworkCredential creds, ContextOptions contextOptions) в System.DirectoryServices.AccountManagement.CredentialValidator.Validate(String userName, String password) в System.DirectoryServices.AccountManagement.PrincipalContext.ValidateCredentials(String userName, String password) в DV.Form1.button1_Click(Object sender, EventArgs e) в System.Windows.Forms.Control.OnClick(EventArgs e) в System.Windows.Forms.Button.OnClick(EventArgs e) в System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) в System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) в System.Windows.Forms.Control.WndProc(Message& m) в System.Windows.Forms.ButtonBase.WndProc(Message& m) в System.Windows.Forms.Button.WndProc(Message& m) в System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) в System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) в System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) This exception is triggered only for those users who do not have local admin rights.
Checked on users with the rights of the local administrator, they have everything ok.
Attention question:
Why are the files not programmatically created, and the hands to create folders and files in Windows (through Explorer) turns out?
Also in app.manifest indicated the launch from the admin, the result is negative.
Code:
PrincipalContext prCont = new PrincipalContext(ContextType.Domain, "kakoytodomen.ru"); string pathLog = @"C:\Users\" + SystemInformation.UserName + @"\Documents\dvlog.log"; //Путь к log файлу //Функция записи в лог (в зависимости от переданного пути). public void ToLogCommon(string text, string path) { Encoding enc = Encoding.GetEncoding(1251); try { StreamWriter f_out = new StreamWriter(@"" + path, true, enc); f_out.WriteLine(DateTime.Now.ToLocalTime() + " " + text); f_out.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } //Кнопка Enter. public void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox2.Text == "") { return; } else { if (prCont.ValidateCredentials(textBox1.Text.Trim(), textBox2.Text.Trim())) { if (IsUserGroupMember(textBox1.Text.Trim(), "DV_DVID")) { form2.ToLogCommon("Вход выполнен: " + textBox1.Text, form2.pathLog); form2.Show(); this.Opacity = 0; } else { form2.ToLogCommon("Данного пользователя: " + textBox1.Text.Trim() + " нет в группе DV_DVID. Доступ запрещён.\r\n", form2.pathLog); MessageBox.Show("Доступ запрещён!\r\nДанного пользователя: " + textBox1.Text.Trim() + " нет в группе DV_DVID.\r\nНеобходимо оформить заявку в СПП.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { form2.ToLogCommon("Логин или пароль введен неверно! Проверьте правильность введённых данных.\r\n", form2.pathLog); MessageBox.Show("Логин или пароль введен неверно!\r\nПроверьте правильность введённых данных.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }