Python win32con.NameSamCompatible() Examples
The following are 5
code examples of win32con.NameSamCompatible().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
win32con
, or try the search function
.
Example #1
Source File: scp.py From ironpython2 with Apache License 2.0 | 5 votes |
def SpnRegister( serviceAcctDN, # DN of the service's logon account spns, # List of SPNs to register operation, # Add, replace, or delete SPNs ): assert type(spns) not in [str, unicode] and hasattr(spns, "__iter__"), \ "spns must be a sequence of strings (got %r)" % spns # Bind to a domain controller. # Get the domain for the current user. samName = win32api.GetUserNameEx(win32api.NameSamCompatible) samName = samName.split('\\', 1)[0] if not serviceAcctDN: # Get the SAM account name of the computer object for the server. serviceAcctDN = win32api.GetComputerObjectName(win32con.NameFullyQualifiedDN) logger.debug("SpnRegister using DN '%s'", serviceAcctDN) # Get the name of a domain controller in that domain. info = win32security.DsGetDcName( domainName=samName, flags=dscon.DS_IS_FLAT_NAME | dscon.DS_RETURN_DNS_NAME | dscon.DS_DIRECTORY_SERVICE_REQUIRED) # Bind to the domain controller. handle = win32security.DsBind( info['DomainControllerName'] ) # Write the SPNs to the service account or computer account. logger.debug("DsWriteAccountSpn with spns %s") win32security.DsWriteAccountSpn( handle, # handle to the directory operation, # Add or remove SPN from account's existing SPNs serviceAcctDN, # DN of service account or computer account spns) # names # Unbind the DS in any case (but Python would do it anyway) handle.Close()
Example #2
Source File: test_windows.py From vnpy_crypto with MIT License | 5 votes |
def test_username(self): self.assertEqual(psutil.Process().username(), win32api.GetUserNameEx(win32con.NameSamCompatible))
Example #3
Source File: test_windows.py From psutil with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_username(self): self.assertEqual(psutil.Process().username(), win32api.GetUserNameEx(win32con.NameSamCompatible))
Example #4
Source File: utils.py From Fastir_Collector with GNU General Public License v3.0 | 5 votes |
def check_permissions(path, logger): logger.info("I am", win32api.GetUserNameEx(win32con.NameSamCompatible)) logger.info(path) sd = win32security.GetFileSecurity(path, win32security.OWNER_SECURITY_INFORMATION) owner_sid = sd.GetSecurityDescriptorOwner() name, domain, _ = win32security.LookupAccountSid(None, owner_sid) logger.info("File owned by %s\\%s" % (domain, name))
Example #5
Source File: test_windows.py From jarvis with GNU General Public License v2.0 | 5 votes |
def test_username(self): self.assertEqual(psutil.Process().username(), win32api.GetUserNameEx(win32con.NameSamCompatible))