|
security
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
list of usersHello,
For days now I am trying. Is it Possible for me to get a list of Users and a list of Group Memebership onto a table of query in my database OK. It's just a matter of writing the output to a recordset instead of to
debug. That's standard programming, not really to do with the list of users. Here's (untested, just wrote it) code for the sample list given (original code has >) This uses DAO, meaning you must have a reference to DAO not ADO. It also assumes you already have a blank table with a field "UserName". > Function faq_ListGroupsOfUser (strUserName As String) Dim db As Database> Dim ws As WorkSpace > Dim usr As User > Dim i As Integer Dim rst As Recordset Set db = CurrentDb() Set rst = db.OpenRecordset("YourTable") > '> Debug.Print usr.Groups(i).Name> Set ws = DBEngine.Workspaces(0) > Set usr = ws.Users(strUserName) > For i = 0 To usr.Groups.count - 1 rst.AddNew rst!UserName= usr.Groups(i).Name rst.Update > Next i rst.Close> End Function Set rst = Nothing Show quoteHide quote "Levans digital" <Levansdigi***@discussions.microsoft.com> wrote in message news:140798C3-29A3-492C-A4FE-627A04955867@microsoft.com... > Hello, > > For days now I am trying. > Is it Possible for me to get a list of Users and a list of Group Memebership > onto a table of query in my database Umm...End Function should be the last line...told you it was untested :-)
And this puts out Username and Groupname if you have those table fields - you get the idea. > Function faq_ListGroupsOfUser (strUserName As String) Dim db As Database> Dim ws As WorkSpace > Dim usr As User > Dim i As Integer Dim rst As Recordset Set db = CurrentDb() Set rst = db.OpenRecordset("YourTable") > '> Debug.Print usr.Groups(i).Name> Set ws = DBEngine.Workspaces(0) > Set usr = ws.Users(strUserName) > For i = 0 To usr.Groups.count - 1 rst.AddNew rst!UserName = strUserName rst!GroupName = usr.Groups(i).Name rst.Update > Next i rst.CloseSet rst = Nothing Show quoteHide quote > End Function And to do it for all users...put this in something which calls the faq
function. (How'm I doing?) (comes roughly from Help on Users Collection example) Dim wrkDefault As Workspace Dim usrLoop As User Set wrkDefault = DBEngine.Workspaces(0) With wrkDefault For Each usrLoop In .Users faq_ListGroupsOfUser (usrLoop.Name) Next usrLoop end with Hey!
Thanks I get the idea. However I should tell you that I am just getting started in VB. Where should I place this "untested code"? Thanks With respect, there's a weeny problem here. Manipulating Users and Groups with
code is a very sophisticated thing to do. You're supposed to wear a Tuxedo to a party like that! Most apps just don't need to do anything like it. I appreciate your enthusiasm, but this is now into general Access programming and we could go on forever. If you're just experimenting/learning, why start off at the deepest end? I can't tell you where to place the code. The original faq was written as a function, meaning it's a piece of code that can be called from other code (such as my last one). Where you place my last one is anywhere you like. For instance, create a new form, place a command button on it, and place it in the code for the command button. That's how I'd test-run code in a very simple way. Chris Show quoteHide quote "Levans digital" <Levansdigi***@discussions.microsoft.com> wrote in message news:199CEF09-772A-4246-87EF-B98C49795150@microsoft.com... > Hey! > > Thanks I get the idea. However I should tell you that I am just getting > started in VB. Where should I place this "untested code"? > > Thanks
Users Group and User Permissions
Security warning when opening a file Patch problem Access 2003 (SP2) Printing Problem Moving .mdw file New security warning messae How can I get an Access database to use data from an outside Form Help: Access 2003 not reading the signatures Set Start up Security to not show Tool Bars and now i can't get in In a shared database, can the administrator boot users |
|||||||||||||||||||||||