Sunday, November 24, 2019

GPUpdate failing due to LDAP Bind Issue

For some reason one computer in my domain cannot update domain policy. Wen I try to force update policy it gives me error:

Computer policy could not be updated successfully. The following errors were encountered:

The processing of Group Policy failed. Windows could not resolve the computer name. This could be caused by one of more of the following:
a) Name Resolution failure on the current domain controller.
b) Active Directory Replication Latency (an account created on another domain controller has not replicated to the current domain controller).
User Policy could not be updated successfully. The following errors were encountered:

The processing of Group Policy failed. Windows could not authenticate to the Active Directory service on a domain controller. (LDAP Bind function call failed). Look in the details tab for error code and description.

To diagnose the failure, review the event log or run GPRESULT /H GPReport.html from the command line to access information about Group Policy results.
Running gpresult /h gives The user does not have RSoP data
Log event viewer shows that that gpupdate fails with an error code 49 Invalid Credentials.

Fix I've found somewhere on serverfault.com

1. Download PsExec from https://docs.microsoft.com/en-us/sysinternals/downloads/psexec
2. From an elevated command prompt run PsExec.exe -i -s cmd.exe
3. From that window, run rundll32.exe keymgr.dll, KRShowKeyMgr (That will open a gui with a list of cached credentials).
4. In that gui, delete any credentials that look suspicious (In my case the credentials were named after my PDC).


Tuesday, July 24, 2018

How to enable disabled account in windows if you could not login.

Almost all the way to enable login in windows assume that you can log in to windows, but what if you cannot? What to do if you accidentally locked you computer?
Solution is pretty simple: Boot from windows CD or USB drive.
When you see windows setup screen press "Shift" + "F10", this open command prompt.
Then you need to replace utilman.exe file to cmd.exe to do this enter following commands:

copy d:\windows\system32\utilman.exe d:\
copy /y d:\windows\system32\cmd.exe d:\windows\system32\utilman.exe

Usually windows is located on drive d: if it is located in different drive correct commands accordingly.

Now type:

wpeutil reboot

after PC reboots and you see login screen press "Easy Of Access" icon and command prompt opens.

Now you can enable disabled users. For example if you want to enable disabled builtin administrator:

net user Administrator /active:yes

Now reboot computer and try to login with administrator account.

Friday, July 20, 2018

User profile service failed to sign in

Logon to windows(in my case win8.1) failed with error "user profile service failed to sign in", "user profile cannot be loaded". I was able to create user, but it was impossible to login with that user. Users with already created profiles can login without any problem.
After browsing internet for one day no solution was found. I check system integrity (sfc /scannow), check disk for errors (chkdsk), made restore of system files (dism utility), check registry and etc. All was unsuccessful. The problem was that something was wrong with default profile permissions. To fix this issue go to c:\Users\Default right click on that folder, select "properties"->"security"->"advanced"->"change permissions"->select checkbox "replace all child object permission entries from this object"  and click "OK"

Then try to login.

Monday, May 7, 2018

Login to ESET ERA web console failed

Login to ESET virtual appliance failed with message Connection failed with state "Not Connected"
This happens after ERA updates and restarts.
Solution is to edit MySQL configuration file located at /etc/opt/eset/RemoteAdministrator/Server/StartupConfiguration.ini
with right connection string. Issue command as root or sudo:

sed -i 's/MySQL ODBC 5.3/MySQL ODBC 8.0/g' /etc/opt/eset/RemoteAdministrator/Server/StartupConfiguration.ini
this command just replaces MySQL ODBC 5.3 to MySQL ODBC 8.0 in connection string.
After that restart MySQL:

service mysqld restart

and restart era service

service eraserver restart


Wednesday, March 7, 2018

How to enable remote dektop remotely.

1. Open "Active Directory Users and Computers"
2. Find the computer
3. Right click on it and select manage
4. Expand "Services and Applications" and select "Services"
5. Find "Remote registry" service and start it.
6. Press "WIN" + "R" and type regedit
7. From Registry editor select "File..." -> "Connect Network Registry.."
8. Find the computer and press "OK" button
9. In connected registry go to "HKEY_LOCAL_MACHINE\SYSTEM|CurrentControlSet\Control\Terminal Server\"
10. Find "fDenyTSConnections" and set it to "0"
11. Connect to remote desktop.


Wednesday, February 21, 2018

Xubuntu. No network with Intel I219-V ethernet card

xubuntu 16.04 does not recognize Intel I219-V Ethernet card.
solution is to download driver sources from Intel Downloads Site then unpack sources to your home catalog. Find file nvm.c file and open it in editor.
Find function e1000e_validate_nvm_checksum_generic(struct e1000_hw *hw) and comment body as shown:

s32 e1000e_validate_nvm_checksum_generic(struct e1000_hw *hw)
{
    /*
s32 ret_val;
u16 checksum = 0;
u16 i, nvm_data;

for (i = 0; i < (NVM_CHECKSUM_REG + 1); i++)
{
    ret_val = e1000_read_nvm(hw, i, 1, &nvm_data);

   if (ret_val)
  {
    e_dbg("NVM Read Error\n");
    return ret_val;
   }
checksum += nvm_data;
}

if (checksum != (u16)NVM_SUM) {
  e_dbg("NVM Checksum Invalid\n");
  return -E1000_ERR_NVM;
}
    */
return 0;
}

after that, build and install new module:

make

sudo rmmod e1000e
sudo make install
sudo modprobe e1000e



after that Ethernet should work.

Tuesday, December 12, 2017

How to remove unused USB serial ports in windows and change port numbers

Sometimes when you connect usb to serial adapter to your pc it gets com number with very high numbers. Not every software can handle that big port numbers. For example some programs cannot work with port numbers higher than com20. So if 20 com ports are in use it is impossible to use that software.  That happens because every time you plug in new USB to serial adapter it gets new com port number, and even if you do not use it anymore port is marked as "in use".
To delete these ports open elevated command prompt: find cmd, right click on it and select "run as administrator".
Then type:

set DEVMGR_SHOW_NONPRESENT_DEVICES=1

after that run device manager:

devmgmt.msc

Enable "Show hidden devices" in the "View" menu, and uninstall grayed-out COM ports

After that you can change your device com port number: right click on it, select properties, then  advanced setting.

Friday, August 25, 2017

Remotely rename computer in windows domain.

run from cli:

netdom renamecomputer old_name  /newname:new_name  /userd:domain_admin_login  /passwordd:domain_admin_pwd

computer will be renamed after restart. If add /reboot:10 computer will be forsibly rebooted after 10 seconds.

Wednesday, August 9, 2017

How to unbrick Arduino Pro Micro 3v3 8MHz version

Recently a made a project with 3v3 version of arduino  pro micro. And accidentally uploaded sketch for arduino Micro. After that I got bricked arduino board. It was not recognized by windows, there was problems with usb enumeration(also "device descriptor request failed", "unrecognized device" etc.).
It seems that problem was with wrong bootloader, so I took my USBasp, connected it to arduino board. From arduino IDE selected right board - "SparkFun Pro Micro", selected processor Atmega32U4 (3.3V 8MHz) and tried to burn bootloader. Got an error - "verification error, first mismatch at byte 0x0000 0xce != 0xfe".
Then I tried to flash bootloader from 5V 16Mhz version, and it was uploaded successfully, but surely because of wrong crystal settings board was still bricked("usb enumeration problems").
So, solution for this is very easy, all you need is swap 3v3 and 5v bootloaders and load bootloader as it was 5v version.

To do this go to:
c:\Users\<username>\AppData\Roaming\Arduino15\packages\SparkFun\hardware\avr\1.1.6\bootloaders\caterina\

and find files Caterina-promicro8.hex and  Caterina-promicro16.hex then rename these files so Caterina-promicro8 -> Caterina-promicro16,  
Caterina-promicro16 -> Caterina-promicro8

after that go to arduino IDE, select SparkFun Pro Micro board,
select Processor Atmega32U4 (5V 16MHz),
select programmer "USBasp",
connect board to programmer and hit "Burn bootloader"

After that board was functional again.
Do not forget to rename bootloader files back to original.
If you do not have USBasp you can use another arduino board as programmer,but do not forget that levels must be the same 5v or 3v3 or use level shifters.

Tuesday, February 21, 2017

Fixed names for usb devices in linux

usb devices appear as /dev/ttyUSB<somenumber> devices. When you plug it to another USB port <somenumber> is unpredictable and you always wasting time to figure out what is the right port number for your device.
To fix this, you can create "udev" rules, so every time you plug in your device there will be the same sym link created for that particular device.

Check vendor and product id with lsusb command:

~# lsusb
Bus 001 Device 011: ID 0403:6001 FTDI FT232 USB-Serial (UART) IC 
Bus 001 Device 010: ID 0403:6001 FTDI FT232 USB-Serial (UART) IC 

ok, we have 2 FTDI chips and we can't distinguish which chip is from what device.
Let's check device serial number(we know that it is connected to ttyUSB0):

~# udevadm info -a -n /dev/ttyUSB0 | grep '{serial}'
 ATTRS{serial}=="0000:00:14.0"

Then go to /etc/udev/rules.d and create file 99-usb-serial.rules
~#sudo touch 99-usb-serial.rules

open file for edit and add these line:

SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="0000:00:14.0", SYMLINK+="arduino"

Now everytime when you plug in your board it will be accesible via symlink /dev/arduino

~# ls -l /dev/arduino 
lrwxrwxrwx 1 root root 7 Nov 15 20:11 /dev/arduino -> ttyUSB0

~# ls -l /dev/ttyUSB0
crw-rw---- 1 root uucp 188, 0 Nov 15 20:11 /dev/ttyUSB1

Wednesday, October 19, 2016

Ubuntu. Cannot upgrade because of full /boot partition. Freeing some space

If you try to upgrade linux distribution (for example from 14.04 to 16.04) sometimes upgrade fail because of no free space at /boot partition. This happens because there are old kernel installed that are no longer needed. To remove old kernel you shoul issue command like this:

sudo apt-get purge linux-image-x.x.x-xx-generic

where "x" are numbers. so you remove all kernels except one that is used. ( check it with uname -r command). Usually in /boot partition there are many of kernels, so removing them one by one is time consuming operation. To make it more convenient use that crazy long command and wait :)

sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")

 It remove all unused kernels from your /boot partition.

Thursday, October 13, 2016

How to check your "external" ip from command line.

Sometimes when you are behind the NAT you need to know what is your "external" IP address.
You can check it from browser(for ex. http://whatismyip.org), but what if you have only command line? Just type in these lines:

nslookup myip.opendns.com. resolver1.opendns.com

do not forget dot "." after first host.

Thursday, October 6, 2016

Install x11vnc on xubuntu 16.04 for remote access

Tight VNC server opens new session, but if you need to connect to active session(like in teamviewer when user see what you are doing) I suggest to install x11vnc.
Installation process as follows:

sudo apt-get install x11vnc -y

next - specify password for remote connections:

sudo x11vnc -storepasswd /etc/x11vnc.pass

now create service unit file:

sudo touch /lib/systemd/system/x11vnc.service

and open it in editor:

sudo nano /lib/systemd/system/x11vnc.service

paste to file:

[Unit] 
Description=Start x11vnc at startup. 
After=multi-user.target
[Service] 
Type=simple 
ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /etc/x11vnc.pass -rfbport 5900 -shared 
[Install] 
WantedBy=multi-user.target

 now configure service:

sudo systemctl enable x11vnc.service  
sudo systemctl daemon-reload

now reboot and try to connect to x11vnc.

Wednesday, September 28, 2016

How to change product key in Office 2016.

There is no option to change product key in "Add/Remove programs" trough control panel.
Instead of using Control Panel, run command prompt with administrative privileges and run following commands:

to check key status:

For Office 2016 32bit on 32bit version of Windows
cscript "C:\Program Files\Microsoft Office\Office16\OSPP.VBS" /dstatus

For Office 2016 32bit on 64bit version of Windows
cscript "C:\Program Files (x86)\Microsoft Office\Office16\OSPP.VBS" /dstatus 

For Office 2016 64bit on 64bit version of Windows
cscript "C:\Program Files\Microsoft Office\Office16\OSPP.VBS" /dstatus

you'll get installed license details and last 5 character of Product Key.

you can change product key by entering command /inpkey:value for example:

cscript "C:\Program Files\Microsoft Office\Office16\OSPP.VBS" /inpkey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

Friday, September 23, 2016

Exchange 2013. Got error 500 when try to login to ECP.

Problem: when trying to access exchange control panel, after entering credentials server returns error 500. If you look to event viewer you find the errors like this:

System.InvalidOperationException: Cannot load Counter Name data because an invalid index 'W3SVC_W3WP' was read from the registry.

Login to OWA is working normally.

Solution: On server run command prompt with administrative privilegies and run command:

lodctr /R

If you get an error, try to run again. After it finished with success,  restart IIS with command

iisrestart

After that try to login to ECP.

Friday, September 2, 2016

Exchange 2013. Add mailbox from powershell.

Check database name:

Get-MailBoxDatabase

for existing user mailenable it:

Enable-Mailbox estherv@contoso.com -Database UsersMailboxDatabase

if you create new user:

New-Mailbox -Alias pilarp -Name "Pilar Pinilla" -FirstName Pilar -LastName Pinilla -DisplayName "Pilar Pinilla" -UserPrincipalName pilarp@contoso.com -Password (ConvertTo-SecureString -String 'Pa$$word1' -AsPlainText -Force)

add additional email addresses if needed:

Set-Mailbox "Tom Taylor" -EmailAddresses @{add="tomt@acme.com","tom.taylor@acme.com"} 

choose default reply to address:

Set-Mailbox "Tom Taylor" -PrimarySmtpAddress tom.taylor@acme.com

if mailbox is configured to use an email address policy then you shoul disable it first(before doing previous step):

Set-Mailbox "Tom Taylor" -EmailAddressPolicyEnabled $false

check is user created:

Get-Mailbox <Name> | FL Name,RecipientTypeDetails,PrimarySmtpAddress

check what distribution group configured

Get-DistributionGroup

Add mailbox to distribution group

Add-DistributionGroupMember -Identity "Staff" -Member "tomtaylor@acme.com" 


Wednesday, August 24, 2016

How to turn on "save as..." prompt on Microsoft Edge browser

I really miss the "save as" prompt in Microsoft edge browser. By default it just start to download file without asking where i want to save it. By default it save file to user's profile "download" directory, but what to do if you have no space on that drive and need to download large file? Fortunately there are solution.

  • Open command prompt or press "win"+r keys. 
  • Type in "regedit" and press "enter".
  • Navigate to key HKEY_CURRENT_USER\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\
  • If there no "Download" key create it.
  • Navigate to Download key and create DWORD value "EnableSavePrompt"
  • Assign value "1" if you want "Save As..." prompt or "0" to turn off.

Tuesday, August 23, 2016

Ubuntu 16.04. How to generate self signed SSl certificate for NGINX and add it to trusted list.

First you need to generate self-signed certificate to NGINX:

Create directory for certificates:

sudo mkdir /etc/nginx/ssl

Now generate ssl certificate:

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt

  • openssl: This is the basic command line tool for creating and managing OpenSSL certificates, keys, and other files.
  • req: This subcommand specifies that we want to use X.509 certificate signing request (CSR) management. The "X.509" is a public key infrastructure standard that SSL and TLS adheres to for its key and certificate management. We want to create a new X.509 cert, so we are using this subcommand.
  • -x509: This further modifies the previous subcommand by telling the utility that we want to make a self-signed certificate instead of generating a certificate signing request, as would normally happen.
  • -nodes: This tells OpenSSL to skip the option to secure our certificate with a passphrase. We need Nginx to be able to read the file, without user intervention, when the server starts up. A passphrase would prevent this from happening because we would have to enter it after every restart.
  • -days 365: This option sets the length of time that the certificate will be considered valid. We set it for one year here.
  • -newkey rsa:2048: This specifies that we want to generate a new certificate and a new key at the same time. We did not create the key that is required to sign the certificate in a previous step, so we need to create it along with the certificate. The rsa:2048 portion tells it to make an RSA key that is 2048 bits long.
  • -keyout: This line tells OpenSSL where to place the generated private key file that we are creating.
  • -out: This tells OpenSSL where to place the certificate that we are creating.
you will be asked for some questions:

Country Name (2 letter code) [AU]:US 
State or Province Name (full name) [Some-State]: New York
Locality Name (eg, city) []:New York City
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Acme, Inc. 
Organizational Unit Name (eg, section) []:Research dep.
Common Name (e.g. server FQDN or YOUR name) []:your_domain.com 
Email Address []:admin@your_domain.com  

Now self signed certificate generated, we need to configure NGINX to use SSL.

open nginx site config file. (usually /etc/nginx/sites-available/<some_name>.conf

you will find something like this:

server { 

          listen 80 default_server; 
          listen [::]:80 default_server ipv6only=on; 

          root /usr/share/nginx/html; 
          index index.html index.htm; 

          server_name your_domain.com; 

          location / { 
                    try_files $uri $uri/ =404; 
         


 Add the following lines:

server { 

          listen 80 default_server; 
          listen [::]:80 default_server ipv6only=on; 

          listen 443 ssl;

          root /usr/share/nginx/html; 
          index index.html index.htm; 

          server_name your_domain.com; 
          ssl_certificate /etc/nginx/ssl/nginx.crt;
          ssl_certificate_key /etc/nginx/ssl/nginx.key; 

          location / { 
                    try_files $uri $uri/ =404; 
         
}

save and close file, then restart nginx:

sudo service nginx restart

Then test is your site accessible via https. Open browser and select https: instead of http.
You likely get a warning that you site use untrusted certifcate. That is normal because we use self-signed certificate.

Now if we want to communicate with this server from another machine using https: we need to add our certificate to "trusted list" on another machine:

go to /usr/local/share/ca-certificates/, create new folder folder and copy .crt file.

cd /usr/local/share/ca-certificates
sudo mkdir <dir_name>


make sure that permissions are OK. 755 for the folder and 644 for file.

Next you should update certificate list:

sudo update-ca-certificates


-------- method 2 -----------

go to /usr/share/ca-certificates:

cd  /usr/share/ca-certificates

create new dir.

sudo mkdir <dir_name>

issue command:

sudo dpkg-reconfigure ca-certificates

 
sudo dpkg-reconfigure ca-certificates calls update-ca-certificates internally



P.S.

I noticed that this will not help if you use try to connect to server using python and urllib3. I always got message:

 [SSL: CERTIFICATE_VERIFY_FAILED]

this was solved to add VERIFY='path_to_certificate_file' in requests.post() function

Friday, January 8, 2016

Python 3.5.0 do not install on Win7 64bit


Installation was finished with error :

Error 0x80240017: Failed to execute MSU package.

After googling for around an hour solution was founded. All you need is uninstall microsoft update KB2999226. Go to windows update -> installed updates -> find that update and uninstall.
After that start python instalation.

Tuesday, June 30, 2015

Ubuntu server change NIC name p5p1 to eth0

After instalation of ubuntu server, got some strange NIC names like p5p1. Let's change it to something more convinient.

edit /etc/default/grub file

sudo nano /etc/default/grub

Modify line:

GRUB_CMDLINE_LINUX_DEFAULT="net.ifnames=0 biosdevname=0"

make new grub.cfg file:

sudo grub-mkconfig -o /boot/grub/grub.cfg

reboot server. After reboot you need to edit /etc/network/interfaces file:

sudo nano /etc/network/interfaces

change p5p1 to eth0, save file and start eth0 interface:

sudo ifconfig eth0 up