當前位置: 首頁>>代碼示例>>Python>>正文


Python win32con.NameSamCompatible方法代碼示例

本文整理匯總了Python中win32con.NameSamCompatible方法的典型用法代碼示例。如果您正苦於以下問題:Python win32con.NameSamCompatible方法的具體用法?Python win32con.NameSamCompatible怎麽用?Python win32con.NameSamCompatible使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在win32con的用法示例。


在下文中一共展示了win32con.NameSamCompatible方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: SpnRegister

# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import NameSamCompatible [as 別名]
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() 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:38,代碼來源:scp.py

示例2: test_username

# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import NameSamCompatible [as 別名]
def test_username(self):
        self.assertEqual(psutil.Process().username(),
                         win32api.GetUserNameEx(win32con.NameSamCompatible)) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:5,代碼來源:test_windows.py

示例3: check_permissions

# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import NameSamCompatible [as 別名]
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)) 
開發者ID:SekoiaLab,項目名稱:Fastir_Collector,代碼行數:9,代碼來源:utils.py


注:本文中的win32con.NameSamCompatible方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。