Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7621455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:11:59+00:00 2026-05-31T04:11:59+00:00

I am currently having a problem accessing Windows print shares ( at work, so

  • 0

I am currently having a problem accessing Windows print shares (at work, so I don’t reall have access to their settings) in Ubuntu, so I eventually got down to poking around the source of Gnome’s ‘system-config-printer‘ which is written in Python, and uses the Python smbc bindings for Samba.

 

I have basically managed to get down my problem to this piece of code, which comes from /usr/share/system-config-printer/pysmb.py, and which I run in the python command line shell:

import smbc, os 
def do_auth (svr, shr, wg, un, pw):
  return ("myworkdomain.com", "MYWORKUSERNAME", "MYWORKPASSWORD")

ctx = smbc.Context (debug=10, auth_fn=do_auth)
f = ctx.open ("smb://%s/%s" % ("printserver.myworkdomain.com", "PRINTSHARENAME"), os.O_RDWR, 0777)

 

The first (sort of) a problem is that upon the execution of the ctx = smbc.Context... line, Python always complains:

params.c:OpenConfFile() - Unable to open configuration file "/home/MYUSERNAME/.smb/smb.conf":
    No such file or directory

… but maybe that is not really a problem? (maybe smbc is supposed to recreate this file anew?).

 

The big problem is, of course, that I cannot connect to the share: after executing the f = ctx.open... line, there is a big dump of Samba communication, Windows server seems to be talking etc – and the connection effort finishes with failure:

SPNEGO login failed: Logon failure
cli_init_creds: user  domain myworkdomain.com
 session setup ok
map_errno_from_nt_status: 32 bit codes: code=c0000022
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
smbc.PermissionError: (13, 'Permission denied')

Basically, I know too little about Samba to be able to read the rest of the error log, but I find the line:

cli_init_creds: user  domain myworkdomain.com

… very suspicious – it looks as if the ‘user‘ there is an empty string – even though I’d expect it to be ‘MYWORKUSERNAME‘, as specified by the ‘do_auth‘ function above!!

Note that this failure is somewhat similar to the NT_STATUS_LOGON_FAILURE that I used to get with the cmdline smbclient (see Obtaining Windows printer share SMB settings (for tsclient/rdesktop on Linux) – Super User), which was solved by explicity specifying a Windows workgroup on the command line – however, I cannot tell if that is also the problem here in the Python case; or if instead, the username is not passed here (or something completely third). EDIT: this working command line (which lists shares) is (in respect to this example):

smbclient -L \\printserver.myworkdomain.com -U MYWORKUSERNAME -W myworkdomain.com

 

Thanks in advance for any suggestions,
Cheers!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:12:01+00:00Added an answer on May 31, 2026 at 4:12 am

    Ok, well, I think I finally got it, thanks to comments in Bug #848065 “system-config-printer cannot authenticate Windows Samba printer, while smbclient can (cli_init_creds)” – and reviewing newprinter.py (from system-config-printer)…

    But first of all, a little overview:

    • My local username on my Ubuntu machine: MYUSERNAME
    • Main address (domain) of the work network: myworkdomain.com
    • My account name on the work network: MYWORKUSERNAME
    • My work account is a member of workgroup MYWORKGROUP, which also has a subdomain myworkgroup.myworkdomain.com
    • The print server on the work network is at printserver.myworkdomain.com
    • The printer name (share) on the print server at work I want to access is PRINTSHARENAME

     

    Well, it turns out that a single line in the test.py script above is wrong – instead of:

    return ("myworkdomain.com", "MYWORKUSERNAME", "MYWORKPASSWORD")

    … one should have had:

    return ("MYWORKGROUP", "MYWORKUSERNAME", "MYWORKPASSWORD")

    … (with MYWORKGROUP in allcaps, as typical for Windows)

     

    Interestingly, using the workgroup subdomain does not work:

    return ("myworkgroup.myworkdomain.com", "MYWORKUSERNAME", "MYWORKPASSWORD")

    … as it will also fail with ‘smbc.PermissionError: (13, 'Permission denied')‘ (just like the original post example).

     

    One way to troubleshoot the “permission denied” error is to check the log – it shows something like this:

        DomainNameLen            : 0x000c (12)
        DomainNameMaxLen         : 0x000c (12)
        DomainName               : *
            DomainName               : 'myworkdomain.com'
        UserNameLen              : 0x0004 (4)
        UserNameMaxLen           : 0x0004 (4)
        UserName                 : *
            UserName                 : 'MYWORKUSERNAME'
        WorkstationLen           : 0x0012 (18)
        WorkstationMaxLen        : 0x0012 (18)
        Workstation              : *
            Workstation              : 'MYPC'
    

    … apparently, the DomainName should be:

            DomainName               : 'MYWORKGROUP'
    

     

    For reference, here is a snippet of the log from the “working” setup (with return ("MYWORKGROUP" ...):

    ...
    cli_init_creds: user MYWORKUSERNAME domain MYWORKGROUP
     session setup ok
     tconx ok
    ...
    Could not retrieve case sensitivity flag: NT_STATUS_INVALID_DEVICE_REQUEST.
    Server connect ok: //printserver.myworkdomain.com/PRINTSHARENAME: 0xa297768
    Performing aggressive shutdown.
    ...
    smbc_remove_usused_server: 0xa297768 removed.
    Context 0xa276658 successfully freed
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently having the problem that I have a (partial) program that is
I'm currently having a problem with a ShoppingCart for my customer. He wants to
I'm trying to build firefox but I'm having some problems. I currently have Visual
I am currently having a problem selecting a certain item from a mySQL database.
I'm currently having a problem with what seems like the Timer_Tick event interfering with
I am having problems accessing the right selector. Currently, on mouseover the ENTIRE grouping
I'm having trouble accessing a dataset. I've pulled data from an Access database (successfully
Im having a problem understanding if accessing httpcontext inside a shared function, without passing
I'm currently having a problem with bitshift operators. I'm not familiar with it so
I'm currently having a problem, trying to wire up exactly one interceptor instance per

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.