How To Manipulate the TRUSTEE PIN Jet Property with ADOX from an ASP Client (272268)



The information in this article applies to:

  • Microsoft Data Access Components 2.6

This article was previously published under Q272268

SUMMARY

This article demonstrates the use of Microsoft ActiveX Data Objects Extensions for Data Definition Language and Security (ADOX) to access different groups, properties, and the new TRUSTEE PIN property that is introduced in MDAC 2.6.

MORE INFORMATION

The following Active Server Pages (ASP) code uses a Microsoft Access 2000 database and performs various operations on the User and Group objects. The code requires that the database be joined to an Access workgroup (.mdw) file.

Create a file called "Testadox.asp" and add the following ASP code to the file:
<%@ Language=VBScript %>
<%

    Dim adoConn         '   As ADODB.Connection
    Dim adoxCat         '   As adox.Catalog
    Dim adoxUsrs        '   As adox.Users
    Dim adoxGrps        '   As adox.Groups
    
    Set adoConn = Server.CreateObject("ADODB.Connection")
    
    ' Try this only against JOLT 4.0.
    ' Note the Jet OLEDB:System database property must be specified.
    adoConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
               & "c:\northwind.mdb;User Id=Admin;Password=thepassword;Jet OLEDB:System database=" _
               & "c:\system1.mdw;"
    Set adoxCat =  Server.CreateObject("ADOX.Catalog")
    
    Set adoxCat.ActiveConnection = adoConn
    ' Displaying the Users Properties.
    Set adoxUsrs = adoxCat.Users
    DispUsers adoxUsrs
    ' Displaying the Groups Properties.
    Set adoxGrps = adoxCat.Groups
    DispGrps adoxGrps
    ' Adding a new user.
    AddUser adoxCat, "User123", "abcd123"
    ' Displaying the User Properties.
    adoxUsrs.Refresh
    DispUsers adoxUsrs
    ' Deleting the User.
    adoxUsrs.Delete ("User123")
    ' Displaying the User Properties.
    adoxUsrs.Refresh
    DispUsers adoxUsrs

    Set adoxGrp = Nothing
    Set adoxGrps = Nothing
    Set adoxUsr = Nothing
    Set adoxUsrs = Nothing
    Set adoxCat.ActiveConnection = Nothing
    Set adoxCat = Nothing
    If adoConn.State = adStateOpen Then
        adoConn.Close
    End If
    Set adoConn = Nothing
    Response.End 
       
Sub DispUsers(adoxUsrs)
    Dim adoxUsr 'As adox.User
    Dim prop    'As adox.Property
    Response.Write "<br/><br/>User Property Information<br/>"
    Response.Write "=========================<br/>"
    For Each adoxUsr In adoxUsrs
        Response.Write"User Name: " & adoxUsr.Name & "<br/>"
        For Each prop In adoxUsr.Properties
            Response.Write prop.Name & ": " & prop.Value  & "<br/>"
        Next 
        Response.Write ( "<br/>")
    Next 
End Sub

Sub DispGrps(adoxGrps)
    Dim adoxGrp     '   As adox.Group
    Dim prop        '   As adox.Property
    Response.Write "<br/><br/>Group Property Information<br/>"
    Response.Write "==========================<br/>"
    For Each adoxGrp In adoxGrps
        Response.Write "Group Name: " & adoxGrp.Name & "<br/>"
        For Each prop In adoxGrp.Properties
          Response.Write prop.Name & ": " & prop.Value  & "<br/>"
        Next 
        Response.Write("<br/>")
    Next 
End Sub

Sub AddUser(adoxCat, usrName , usrPwd )
    Dim adoxUsr     'As adox.User
    Set adoxUsr =   Server.CreateObject("adox.User")
    adoxUsr.ParentCatalog = adoxCat
    adoxUsr.Name = usrName
    adoxUsr.Properties("Jet OLEDB:Trustee Pin") = "DonkeyKong"
    adoxUsr.ChangePassword "", usrPwd
    adoxCat.Users.Append adoxUsr
End Sub


%>
				

Modification Type:MinorLast Reviewed:7/1/2004
Keywords:kbhowto KB272268