home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / CODIGO_1 / NIVB_SRC / DIRDIR.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-06-03  |  7.9 KB  |  239 lines

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