Q:

AD login and smbclient login successful, but fails from Windows clients

I am able to login to Ubuntu 16.04 system using AD/LDAP authentication and access everything. However, when I configure samba to connect from windows clients, it fails.
smbclient from another Ubuntu machine is successful and lists all folders
smbclient -k -L serverip -U user%password
  Sharename       Type      Comment
  ---------       ----      -------
   public          Disk
   user            Disk
   IPC$            IPC       IPC Service (Samba Server 4.3.11-Ubuntu)

    Server               Comment
    ---------            -------
    servername         Samba Server 4.3.11-Ubuntu

    Workgroup            Master
    ---------            -------
    workgroup

Can anyone help with the correct smb.conf file for this kind of situation? none of the configs on the internet work. below is my smb.conf
[global]

  workgroup = {{ workgroup}}
  server string = Samba Server %v
  netbios name = server-fqdn
 # Active Directory System
  passdb backend = tdbsam
  security = ads
  idmap config * : range = 1000000-2000000
  os level = 0
  # With .tld
  realm = {{ realm_id }}
  local master = no
  preferred master = no
  domain master = no

  #Auth
  client use spnego = yes
  client ntlmv2 auth = yes
  ntlm auth = yes
  lanman auth = no

  encrypt passwords = yes
  password server = *
  restrict anonymous = 2
  #log
  log file = /var/log/samba/samba.log
  log level = 2
  #mapping
  map to guest = bad user
  guest account = nobody
  unix extensions = yes

 [ubuser]
  path = /opt/samba/ubuser
  valid users = %S, domain\ubuser
  admin users = %S, domain\ubuser
  writable = yes
  read only = no
  force create mode = 0660
  create mask = 0777
  directory mask = 0777
  force directory mode = 0770
  access based share enum = yes
  hide unreadable = yes

The errors i get are
../auth/credentials/credentials_secrets.c:396(cli_credentials_set_machine_account_db_ctx)
  Could not find machine account in secrets database:

[2017/08/29 08:16:16.879389,  0] ../source3/auth/auth_domain.c:121(connect_to_domain_password_server)
  connect_to_domain_password_server: unable to open the domain client session to machine machine.host.com. Error was : NT_STATUS_CANT_ACCESS_DOMAIN_INFO.
[2017/08/29 08:16:16.883324,  1] ../auth/credentials/credentials_secrets.c:396(cli_credentials_set_machine_account_db_ctx)
  Could not find machine account in secrets database: Failed to fetch machine account password for WBI from both secrets.ldb (Could not find entry to match filter: '(&(flatname=domain)(objectclass=primaryDomain))' base: 'cn=Primary Domains': No such object: (null)) and from /var/lib/samba/private/secrets.tdb: NT_STATUS_CANT_ACCESS_DOMAIN_INFO
[2017/08/29 08:16:16.883435,  0] ../source3/auth/auth_domain.c:121(connect_to_domain_password_server)
  connect_to_domain_password_server: unable to open the domain client session to machine machine.host.com. Error was : NT_STATUS_CANT_ACCESS_DOMAIN_INFO.
[2017/08/29 08:16:16.883811,  0] ../source3/auth/auth_domain.c:184(domain_client_validate)
  domain_client_validate: Domain password server not available.
[2017/08/29 08:16:16.884142,  2] ../source3/auth/auth.c:315(auth_check_ntlm_password)
  check_ntlm_password:  Authentication for user [ubuser] -> [ubuser] FAILED with error NT_STATUS_NO_LOGON_SERVERS
[2017/08/29 08:16:16.884211,  2] ../auth/gensec/spnego.c:716(gensec_spnego_server_negTokenTarg)
  SPNEGO login failed: NT_STATUS_NO_LOGON_SERVERS
[2017/08/29 08:16:17.238067,  2] ../source3/librpc/crypto/gse_krb5.c:196(fill_mem_keytab_from_secrets)
  ../source3/librpc/crypto/gse_krb5.c:196: failed to fetch machine password

A:

Solved by setting the correct permissions on the samba  folder.
The permissions should be the same as the user's home folder 

