LisaValbuena
asked on
How do I find out the Active Directory user group a user belongs to from MS Access 2003
From MS Access 2003 and VBA, how do I find out a user accounts details, such as the user group they belong to, so that I can customize which menu options are available to them, without having to create another set of passwords?
By using Windows API calls, I alredy know how to figure out the username, but I am missing the user group from an Active Directory, Windows 2003 Server.
By using Windows API calls, I alredy know how to figure out the username, but I am missing the user group from an Active Directory, Windows 2003 Server.
You can create a user table in access as use their PC login as a means of restricting their usage:
http://www.mvps.org/access/api/api0008.htm Login
http://www.mvps.org/access/api/api0009.htm PC Name
You can also get their directories as so:
http://www.mvps.org/access/api/api0010.htm
http://www.mvps.org/access/api/api0008.htm Login
http://www.mvps.org/access/api/api0009.htm PC Name
You can also get their directories as so:
http://www.mvps.org/access/api/api0010.htm
ASKER
I created the function you wrote about, but when I run it I get an error message:
Run-time rror -2147217865 (800r0e37)
Table Does not exist
Referencing the following line in your code:
Set rs = conn.Execute("<LDAP://DC=t l,DC=local host>;(&(o bjectCateg ory=person )(objectCl ass=user)( sAMAccount Name=" & strUserID & "));adsPath;subTree")
I invoked the function by typing:
? GetUserGroups("Eroth") from the immediate window, "Eroth" being the username connected to the Windows 2003 Network.
Please advise.
Thanks
Run-time rror -2147217865 (800r0e37)
Table Does not exist
Referencing the following line in your code:
Set rs = conn.Execute("<LDAP://DC=t
I invoked the function by typing:
? GetUserGroups("Eroth") from the immediate window, "Eroth" being the username connected to the Windows 2003 Network.
Please advise.
Thanks
You will need to change the
DC=tl,DC=localhost
to the particular domain components - e.g.
DC=YourDomain,DC=YourCompa ny
of
DC=YourDomain,DC=com
DC=tl,DC=localhost
to the particular domain components - e.g.
DC=YourDomain,DC=YourCompa
of
DC=YourDomain,DC=com
ASKER
Thanks for responding and trying to clarify the issue.
I followed your suggestions and replaced the line in question to:
Set rs = conn.Execute("<LDAP://DC=x xxx.local, DC=XXXX>;( &(objectCa tegory=per son)(objec tClass=use r)(sAMAcco untName=" & strUserID & "));adsPath;subTree")
Where xxxx.local is the name of the Domain - I opened the Active Directory Users and Computers - Admininstrator and read it from there.
XXXX Company Name
Still it gives me an error message, not being able to find the table.
Is there a particular syntax that I must follow?
Or how do it find out the correct Domain Name and Company Name spelling as stored in the Active Directory?
As said before, I went to the Active Directory Users & Computers - Management Console screen
Please advise,
Thanks
I followed your suggestions and replaced the line in question to:
Set rs = conn.Execute("<LDAP://DC=x
Where xxxx.local is the name of the Domain - I opened the Active Directory Users and Computers - Admininstrator and read it from there.
XXXX Company Name
Still it gives me an error message, not being able to find the table.
Is there a particular syntax that I must follow?
Or how do it find out the correct Domain Name and Company Name spelling as stored in the Active Directory?
As said before, I went to the Active Directory Users & Computers - Management Console screen
Please advise,
Thanks
Okay, in the Active Directory Users & Computers console screen, on the left side you should see at least a couple of folders under Active Directory Users & Computers. The first should be Saved Queries, the next should be the DC information you are looking for.
So, if that folder is named
ABCD.EFGHI
then use
DC=ABCD,DC=EFGHI
If that folder is named
ABCD.EFGHI.JLK
then use
DC=ABCD,DC=EFGHI ,DC=JKL
So, if that folder is named
ABCD.EFGHI
then use
DC=ABCD,DC=EFGHI
If that folder is named
ABCD.EFGHI.JLK
then use
DC=ABCD,DC=EFGHI ,DC=JKL
ASKER
irudyk:
Thanks ... We are making progress and I was successful in replacing the DC references, as per your suggestions.
The problem I have now, is that if I pass the string in quotes such as:
GetUserGroups("Eroth") it works fine.
But the goal is to replace the username dynamically.
I invoke a Function called GetCurrentUsername() which returns a string, which in turn I should pass to the GetUserGroup function. you are sharing with me.
I have tried several options, enclosing the returned string in quotes, changing the GetUserGroup reference to ByVal, ByRef but I cannot make it work.
Please advise
THANKS in advance.
GetCurrentUserGroupIssue.doc
Thanks ... We are making progress and I was successful in replacing the DC references, as per your suggestions.
The problem I have now, is that if I pass the string in quotes such as:
GetUserGroups("Eroth") it works fine.
But the goal is to replace the username dynamically.
I invoke a Function called GetCurrentUsername() which returns a string, which in turn I should pass to the GetUserGroup function. you are sharing with me.
I have tried several options, enclosing the returned string in quotes, changing the GetUserGroup reference to ByVal, ByRef but I cannot make it work.
Please advise
THANKS in advance.
GetCurrentUserGroupIssue.doc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes ...!!!!
As I was testing, prior to changing the Function to be ByVal, I was enclosing the string in quotes.
THANKS ... THANKS ... THANKS!
As I was testing, prior to changing the Function to be ByVal, I was enclosing the string in quotes.
THANKS ... THANKS ... THANKS!
ASKER
Wonderful ... I appreciate your help.
Sincerely,
EL
Sincerely,
EL
Open in new window