DiskQuotaControl.TranslateLogonNameToSID method

Translates a logon name to the corresponding user security ID in string format.

Syntax

DiskQuotaControl.TranslateLogonNameToSID(
  logonname
)

Parameters

logonname

Type: String

A string value that specifies the user's logon name.

Return value

Returns the user security ID (SID) in string format corresponding to the provided logon name. The returned string includes the standard enclosing braces. For example:

"{S-1-5-21-2127521184-1604012920-1887927527-19009}"

Remarks

The returned SID string can be passed to the FindUser method in place of a logon name.

When a call to the FindUser( logonname) method fails, it could be due to a mismatch between the form (for example, Security Account Manager [SAM] compatible and User Principal Name [UPN]) of the logon name provided and the form stored in the SID-name cache. In such cases, the logon name can be converted to a SID and the call to FindUser repeated. FindUser recognizes a SID string and will bypass the SID-name cache lookup. The following Microsoft Visual Basic Scripting Edition (VBScript) code illustrates this technique.

Function Find(dqc, name)
    On Error Resume Next
    SET Find = dqc.FindUser(name)

    If Err.Number <> 0 Then
        Err.Clear
        SET Find = dqc.FindUser(dqc.TranslateLogonNameToSID(name))
    End If    

End Function

Name-to-SID translation can be a slow process when compared to lookups in the SID-name cache. Therefore, it is recommended that FindUser first be called with a logon name. The example above uses this technique.

Requirements

Requirement Value
Minimum supported client
Windows 2000 Professional, Windows XP [desktop apps only]
Minimum supported server
Windows Server 2003 [desktop apps only]
DLL
Shell32.dll (version 5.0 or later)

See also

DiskQuotaControl Object