home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / nivb_src / dirdir.frm < prev    next >
Text File  |  1993-06-03  |  8KB  |  263 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. End
  99.  
  100. Sub Form_Load ()
  101.     Dim dirEntry As NWDIR_ENTRY
  102.     Dim trustees3x As TRUSTEE_BUFFER_3X
  103.     Dim trustees2x As TRUSTEE_BUFFER_2X
  104.  
  105.     server$ = String$(48, 0)
  106.     volume$ = String$(16, 0)
  107.     dirs$ = String$(255, 0)
  108.  
  109.     ccode% = ParsePath(dirPath$, server$, volume$, dirs$)
  110.     
  111.     volume$ = Left$(volume$, InStr(volume$, Chr$(0)) - 1)
  112.     dirs$ = Left$(dirs$, InStr(dirs$, Chr$(0)) - 1)
  113.     dirPath$ = volume$ + ":/" + dirs$
  114.     
  115.     connID% = GetDefaultConnectionID()
  116.  
  117.     ccode% = AllocTemporaryDirectoryHandle(0, dirPath$, Asc("["), handle%, mask%)
  118.  
  119.     If (ccode% <> SUCCESSFUL) Then
  120.         MsgBox "Unable to allocate directory handle", MB_OK, "Error"
  121.     Else
  122.         ccode% = GetDirEntry(connID%, handle%, dirEntry)
  123.         If (ccode% <> SUCCESSFUL) Then
  124.             MsgBox "Unable to get directory information", MB_OK, "Error"
  125.         Else
  126.             oName$ = String$(48, 0)
  127.  
  128.             ccode% = GetBinderyObjectname(dirEntry.ownerID, oName$, ownerType%)
  129.             If (ccode% = SUCCESSFUL) Then
  130.                 OwnerLabel.Caption = oName$
  131.             Else
  132.                 OwnerLabel.Caption = "Unknown User"
  133.             End If
  134.  
  135.             DirPathLabel = dirPath$
  136.             CreatedLabel.Caption = GetDate$(dirEntry.creationDate, dirEntry.creationTime)
  137.  
  138.             sequence% = 0
  139.             dirName$ = String$(16, 0)
  140.             tRights$ = String$(5, 0)
  141.             
  142.             'Would get the rights mask from the trustee buffer,
  143.             '   but there is a bug in the v1.30 NWNETAPI.DLL, and
  144.             '   ScanEntryForTrustees doesn't copy the rights mask
  145.             '   to the buffer correctly
  146.             Do
  147.                 ver3x% = IsV3Supported(connID%)
  148.                 If (ver3x% = 1) Then
  149.                     ccode% = ScanEntryForTrustees(connID%, 0, dirPath$, trustees3x, sequence%, numTrusteeEntries)
  150.                     If (ccode% = SUCCESSFUL) Then
  151.                         sequence% = sequence% + 1
  152.                         For i = 0 To (Asc(trustees3x.numEntriesReturned) - 1)
  153.                             gotName% = GetBinderyObjectname(trustees3x.oID(i), oName$, oType%)
  154.                             If (gotName% <> 0) Then oName$ = "Unknown User"
  155.                             TrusteeList.AddItem oName$
  156.                         Next i
  157.                     End If
  158.                 Else
  159.                     ccode% = ScanEntryForTrustees(connID%, 0, dirPath$, trustees2x, sequence%, numTrusteeEntries)
  160.                     If (ccode% = SUCCESSFUL) Then
  161.                         sequence% = sequence% + 1
  162.                         For i = 0 To 4
  163.                             If (trustees2x.oID(i) = 0) Then Exit For
  164.                             gotName% = GetBinderyObjectname(trustees2x.oID(i), oName$, oType%)
  165.                             If (gotName% <> 0) Then oName$ = "Unknown User"
  166.                             TrusteeList.AddItem oName$
  167.                         Next i
  168.                     End If
  169.                 End If
  170.             Loop Until (ccode% <> SUCCESSFUL)
  171.         End If
  172.         
  173.         ccode% = GetEffectiveRights(connID%, 0, dirPath$, rights%)
  174.         If (ccode% = SUCCESSFUL) Then
  175.             EffectiveRightsLabel.Caption = GetRights(rights%)
  176.         Else
  177.             EffectiveRightsLabel.Caption = "Unable to obtain"
  178.         End If
  179.  
  180.         ccode% = DeallocateDirectoryHandle(handle%)
  181.         If (ccode% <> SUCCESSFUL) Then
  182.             MsgBox "Unable to deallocate directory handle", MB_OK, "Error"
  183.         End If
  184.     End If
  185. End Sub
  186.  
  187. Function GetRights (rightsMask%)
  188.     If (rightsMask% And TR_SUPERVISOR) Then
  189.         rights$ = "S"
  190.     Else
  191.         rights$ = " "
  192.     End If
  193.  
  194.     If (rightsMask% And TR_MODIFY) Then
  195.         rights$ = rights$ + "M"
  196.     Else
  197.         rights$ = rights$ + " "
  198.     End If
  199.  
  200.     If (rightsMask% And TR_FILE) Then
  201.         If (IsV3Supported(connID%) = 1) Then
  202.             rights$ = rights$ + "F"
  203.         Else
  204.             rights$ = rights$ + "S"
  205.         End If
  206.     Else
  207.         rights$ = rights$ + " "
  208.     End If
  209.  
  210.     If (rightsMask% And TR_ACCESS) Then
  211.         If (IsV3Supported(connID%) = 1) Then
  212.             rights$ = rights$ + "A"
  213.         Else
  214.             rights$ = rights$ + "P"
  215.         End If
  216.     Else
  217.         rights$ = rights$ + " "
  218.     End If
  219.  
  220.     If (rightsMask% And TR_ERASE) Then
  221.         If (IsV3Supported(connID%) = 1) Then
  222.             rights$ = rights$ + "E"
  223.         Else
  224.             rights$ = rights$ + "D"
  225.         End If
  226.     Else
  227.         rights$ = rights$ + " "
  228.     End If
  229.  
  230.     If (rightsMask% And TR_CREATE) Then
  231.         rights$ = rights$ + "C"
  232.     Else
  233.         rights$ = rights$ + " "
  234.     End If
  235.  
  236.     If (IsV3Supported(connID%) <> 1) Then
  237.         If (rightsMask% And TA_OPEN) Then
  238.             rights$ = rights$ + "O"
  239.         Else
  240.             rights$ = rights$ + " "
  241.         End If
  242.     End If
  243.  
  244.     If (rightsMask% And TR_WRITE) Then
  245.         rights$ = rights$ + "W"
  246.     Else
  247.         rights$ = rights$ + " "
  248.     End If
  249.  
  250.     If (rightsMask% And TR_READ) Then
  251.         rights$ = rights$ + "R"
  252.     Else
  253.         rights$ = rights$ + " "
  254.     End If
  255.  
  256.     GetRights = rights$
  257. End Function
  258.  
  259. Sub OKButton_Click ()
  260.     Unload DirDirForm
  261. End Sub
  262.  
  263.