home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / nivb / dirdir.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-07  |  8.0 KB  |  243 lines

  1. VERSION 2.00
  2. Begin Form DirDirForm 
  3.    Caption         =   "Directory Services Test (Directory APIs)"
  4.    ClientHeight    =   3450
  5.    ClientLeft      =   1365
  6.    ClientTop       =   1665
  7.    ClientWidth     =   4905
  8.    Height          =   3855
  9.    Left            =   1305
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3450
  12.    ScaleWidth      =   4905
  13.    Top             =   1320
  14.    Width           =   5025
  15.    Begin ListBox TrusteeList 
  16.       Height          =   1005
  17.       Left            =   240
  18.       TabIndex        =   7
  19.       Top             =   1920
  20.       Width           =   4575
  21.    End
  22.    Begin CommandButton OKButton 
  23.       Caption         =   "&OK"
  24.       Height          =   375
  25.       Left            =   2040
  26.       TabIndex        =   0
  27.       Top             =   3000
  28.       Width           =   975
  29.    End
  30.    Begin Label EffectiveRightsLabel 
  31.       Height          =   255
  32.       Left            =   1680
  33.       TabIndex        =   10
  34.       Top             =   1440
  35.       Width           =   2655
  36.    End
  37.    Begin Label Label5 
  38.       Alignment       =   1  'Right Justify
  39.       Caption         =   "Your effective rights:"
  40.       Height          =   495
  41.       Left            =   120
  42.       TabIndex        =   9
  43.       Top             =   1200
  44.       Width           =   1455
  45.    End
  46.    Begin Label Label4 
  47.       Alignment       =   1  'Right Justify
  48.       Caption         =   "Trustees:"
  49.       Height          =   255
  50.       Left            =   240
  51.       TabIndex        =   8
  52.       Top             =   1680
  53.       Width           =   855
  54.    End
  55.    Begin Label CreatedLabel 
  56.       Height          =   255
  57.       Left            =   1680
  58.       TabIndex        =   6
  59.       Top             =   960
  60.       Width           =   1695
  61.    End
  62.    Begin Label OwnerLabel 
  63.       Height          =   255
  64.       Left            =   1680
  65.       TabIndex        =   5
  66.       Top             =   720
  67.       Width           =   2655
  68.    End
  69.    Begin Label Label3 
  70.       Alignment       =   1  'Right Justify
  71.       Caption         =   "Created:"
  72.       Height          =   255
  73.       Left            =   720
  74.       TabIndex        =   4
  75.       Top             =   960
  76.       Width           =   855
  77.    End
  78.    Begin Label Label2 
  79.       Alignment       =   1  'Right Justify
  80.       Caption         =   "Owner:"
  81.       Height          =   255
  82.       Left            =   960
  83.       TabIndex        =   3
  84.       Top             =   720
  85.       Width           =   615
  86.    End
  87.    Begin Label DirPathLabel 
  88.       Height          =   255
  89.       Left            =   720
  90.       TabIndex        =   2
  91.       Top             =   360
  92.       Width           =   5055
  93.    End
  94.    Begin Label Label1 
  95.       Caption         =   "Information for directory:"
  96.       Height          =   255
  97.       Left            =   240
  98.       TabIndex        =   1
  99.       Top             =   120
  100.       Width           =   2175
  101.    End
  102. Sub Form_Load ()
  103.     Dim dirEntry As NWDIR_ENTRY
  104.     Dim trustees3x As TRUSTEE_BUFFER_3X
  105.     Dim trustees2x As TRUSTEE_BUFFER_2X
  106.     server$ = String$(48, 0)
  107.     volume$ = String$(16, 0)
  108.     dirs$ = String$(255, 0)
  109.     ccode% = ParsePath(dirPath$, server$, volume$, dirs$)
  110.     volume$ = Left$(volume$, InStr(volume$, Chr$(0)) - 1)
  111.     dirs$ = Left$(dirs$, InStr(dirs$, Chr$(0)) - 1)
  112.     dirPath$ = volume$ + ":/" + dirs$
  113.     connID% = GetDefaultConnectionID()
  114.     ccode% = AllocTemporaryDirectoryHandle(0, dirPath$, Asc("["), handle%, mask%)
  115.     If (ccode% <> SUCCESSFUL) Then
  116.         MsgBox "Unable to allocate directory handle", MB_OK, "Error"
  117.     Else
  118.         ccode% = GetDirEntry(connID%, handle%, dirEntry)
  119.         If (ccode% <> SUCCESSFUL) Then
  120.             MsgBox "Unable to get directory information", MB_OK, "Error"
  121.         Else
  122.             oName$ = String$(48, 0)
  123.             ccode% = GetBinderyObjectname(dirEntry.ownerID, oName$, ownerType%)
  124.             If (ccode% = SUCCESSFUL) Then
  125.                 OwnerLabel.Caption = oName$
  126.             Else
  127.                 OwnerLabel.Caption = "Unknown User"
  128.             End If
  129.             DirPathLabel = dirPath$
  130.             CreatedLabel.Caption = GetDate$(dirEntry.creationDate, dirEntry.creationTime)
  131.             sequence% = 0
  132.             dirName$ = String$(16, 0)
  133.             tRights$ = String$(5, 0)
  134.             
  135.             'Would get the rights mask from the trustee buffer,
  136.             '   but there is a bug in the v1.30 NWNETAPI.DLL, and
  137.             '   ScanEntryForTrustees doesn't copy the rights mask
  138.             '   to the buffer correctly
  139.             Do
  140.                 ver3x% = IsV3Supported(connID%)
  141.                 If (ver3x% = 1) Then
  142.                     ccode% = ScanEntryForTrustees(connID%, 0, dirPath$, trustees3x, sequence%, numTrusteeEntries)
  143.                     If (ccode% = SUCCESSFUL) Then
  144.                         sequence% = sequence% + 1
  145.                         For i = 0 To (Asc(trustees3x.numEntriesReturned) - 1)
  146.                             gotName% = GetBinderyObjectname(trustees3x.oID(i), oName$, oType%)
  147.                             If (gotName% <> 0) Then oName$ = "Unknown User"
  148.                             TrusteeList.AddItem oName$
  149.                         Next i
  150.                     End If
  151.                 Else
  152.                     ccode% = ScanEntryForTrustees(connID%, 0, dirPath$, trustees2x, sequence%, numTrusteeEntries)
  153.                     If (ccode% = SUCCESSFUL) Then
  154.                         sequence% = sequence% + 1
  155.                         For i = 0 To 4
  156.                             If (trustees2x.oID(i) = 0) Then Exit For
  157.                             gotName% = GetBinderyObjectname(trustees2x.oID(i), oName$, oType%)
  158.                             If (gotName% <> 0) Then oName$ = "Unknown User"
  159.                             TrusteeList.AddItem oName$
  160.                         Next i
  161.                     End If
  162.                 End If
  163.             Loop Until (ccode% <> SUCCESSFUL)
  164.         End If
  165.         
  166.         ccode% = GetEffectiveRights(connID%, 0, dirPath$, rights%)
  167.         If (ccode% = SUCCESSFUL) Then
  168.             EffectiveRightsLabel.Caption = GetRights(rights%)
  169.         Else
  170.             EffectiveRightsLabel.Caption = "Unable to obtain"
  171.         End If
  172.         ccode% = DeallocateDirectoryHandle(handle%)
  173.         If (ccode% <> SUCCESSFUL) Then
  174.             MsgBox "Unable to deallocate directory handle", MB_OK, "Error"
  175.         End If
  176.     End If
  177. End Sub
  178. Function GetRights (rightsMask%)
  179.     If (rightsMask% And TR_SUPERVISOR) Then
  180.         rights$ = "S"
  181.     Else
  182.         rights$ = " "
  183.     End If
  184.     If (rightsMask% And TR_MODIFY) Then
  185.         rights$ = rights$ + "M"
  186.     Else
  187.         rights$ = rights$ + " "
  188.     End If
  189.     If (rightsMask% And TR_FILE) Then
  190.         If (IsV3Supported(connID%) = 1) Then
  191.             rights$ = rights$ + "F"
  192.         Else
  193.             rights$ = rights$ + "S"
  194.         End If
  195.     Else
  196.         rights$ = rights$ + " "
  197.     End If
  198.     If (rightsMask% And TR_ACCESS) Then
  199.         If (IsV3Supported(connID%) = 1) Then
  200.             rights$ = rights$ + "A"
  201.         Else
  202.             rights$ = rights$ + "P"
  203.         End If
  204.     Else
  205.         rights$ = rights$ + " "
  206.     End If
  207.     If (rightsMask% And TR_ERASE) Then
  208.         If (IsV3Supported(connID%) = 1) Then
  209.             rights$ = rights$ + "E"
  210.         Else
  211.             rights$ = rights$ + "D"
  212.         End If
  213.     Else
  214.         rights$ = rights$ + " "
  215.     End If
  216.     If (rightsMask% And TR_CREATE) Then
  217.         rights$ = rights$ + "C"
  218.     Else
  219.         rights$ = rights$ + " "
  220.     End If
  221.     If (IsV3Supported(connID%) <> 1) Then
  222.         If (rightsMask% And TA_OPEN) Then
  223.             rights$ = rights$ + "O"
  224.         Else
  225.             rights$ = rights$ + " "
  226.         End If
  227.     End If
  228.     If (rightsMask% And TR_WRITE) Then
  229.         rights$ = rights$ + "W"
  230.     Else
  231.         rights$ = rights$ + " "
  232.     End If
  233.     If (rightsMask% And TR_READ) Then
  234.         rights$ = rights$ + "R"
  235.     Else
  236.         rights$ = rights$ + " "
  237.     End If
  238.     GetRights = rights$
  239. End Function
  240. Sub OKButton_Click ()
  241.     Unload DirDirForm
  242. End Sub
  243.