From: vm on 16 Jun 2005 20:59 Thanks - it sounds like what I am looking for, I will give it a try. I use ADSI for other queries on this project. Thanks again vm "Paul Clement" wrote: > On Thu, 16 Jun 2005 11:47:02 -0700, "vm" <vm(a)discussions.microsoft.com> wrote: > > ¤ We are in a multiple trusted domain environment and I am looking to determine > ¤ which domain the logged in user is logged into. People can have accounts with > ¤ the same SID in multiple domains. I have seen the post here about using the: > ¤ Environ$("USERDOMAIN") to extract the domain name. I am wondering if there is > ¤ another way to check. I can extract the domain the workstation is in, but > ¤ have had little luck finding something on finding the domain of the currently > ¤ logged in user on a workstation. > > You can also use ADSI: > > Dim objSystemInfo As Object > Set objSystemInfo = CreateObject("ADSystemInfo") > MsgBox "The current domain is: " & objSystemInfo.DomainShortName > Set objSystemInfo = Nothing > > > Paul > ~~~~ > Microsoft MVP (Visual Basic) >
From: Paul Clement on 17 Jun 2005 13:50 On Thu, 16 Jun 2005 15:29:23 -0700, "Karl E. Peterson" <karl(a)mvps.org> wrote: ý Paul Clement wrote: ý > On Thu, 16 Jun 2005 11:47:02 -0700, "vm" ý > <vm(a)discussions.microsoft.com> wrote: ý > ý > ý We are in a multiple trusted domain environment and I am looking to ý > determine ý which domain the logged in user is logged into. People ý > can have accounts with ý the same SID in multiple domains. I have ý > seen the post here about using the: ý Environ$("USERDOMAIN") to ý > extract the domain name. I am wondering if there is ý another way to ý > check. I can extract the domain the workstation is in, but ý > ý have had little luck finding something on finding the domain of the ý > currently ý logged in user on a workstation. ý > ý > You can also use ADSI: ý > ý > Dim objSystemInfo As Object ý > Set objSystemInfo = CreateObject("ADSystemInfo") ý > MsgBox "The current domain is: " & objSystemInfo.DomainShortName ý > Set objSystemInfo = Nothing ý ý I don't know a lot about ADSI. Is that returning user or workstation domain? ý SystemInfo sounds very workstation-y, eh? Good question. I managed to dig up the doc and it says it's returning the domain name of the host on which the code is running. Now whether this is what he needs I don't know for certain. Unfortunately I'm not in an environment where there is trust between the domains so I can't log into a domain other than that for which my workstation is a member, and test the code. If you need the domain for which the authenticated user is a member you can pull it out of the user's distinguished name: MsgBox objSystemInfo.UserName If you need the domain name which the user is logged in to you can use the RootDSE class: Dim objRootDSE As Object Set objRootDSE = GetObject("LDAP://RootDSE") MsgBox objRootDSE.Get("DefaultNamingContext") Paul ~~~~ Microsoft MVP (Visual Basic)
From: Karl E. Peterson on 17 Jun 2005 15:09 Hi Paul -- > ý > Dim objSystemInfo As Object > ý > Set objSystemInfo = CreateObject("ADSystemInfo") > ý > MsgBox "The current domain is: " & objSystemInfo.DomainShortName > ý > Set objSystemInfo = Nothing > ý > ý I don't know a lot about ADSI. Is that returning user or > workstation domain? > ý SystemInfo sounds very workstation-y, eh? > > Good question. I managed to dig up the doc and it says it's returning > the domain name of the host on which the code is running. > > Now whether this is what he needs I don't know for certain. > Unfortunately I'm not in an environment where there is trust between > the domains so I can't log into a domain other than that for which my > workstation is a member, and test the code. Yeah, it's not readily testable here, either. > If you need the domain for which the authenticated user is a member > you can pull it out of the user's distinguished name: > > MsgBox objSystemInfo.UserName How? I don't see my domain name there, at all. > If you need the domain name which the user is logged in to you can > use the RootDSE class: > > Dim objRootDSE As Object > > Set objRootDSE = GetObject("LDAP://RootDSE") > MsgBox objRootDSE.Get("DefaultNamingContext") That's kinda fuzzy, here. I'm logged into a domain known as "langroup", but I get "DC=clark,DC=root,DC=local" from that example (which corresponds to my primary DNS suffix of "clark.root.local"), same as your objSystemInfo.UserName suggestion. Thanks... Karl -- Working Without a .NET? http://classicvb.org/petition
From: Tony Proctor on 17 Jun 2005 15:22 Why not just call the GetUserNameEx API with a NameFormat of NameSamCompatible. This will return the full SAM-format account name, e.g. domain\user Tony Proctor "vm" <vm(a)discussions.microsoft.com> wrote in message news:10502D5B-9B92-4524-976C-92F5FB13B87D(a)microsoft.com... > We are in a multiple trusted domain environment and I am looking to determine > which domain the logged in user is logged into. People can have accounts with > the same SID in multiple domains. I have seen the post here about using the: > Environ$("USERDOMAIN") to extract the domain name. I am wondering if there is > another way to check. I can extract the domain the workstation is in, but > have had little luck finding something on finding the domain of the currently > logged in user on a workstation. > > Thanks
From: Paul Clement on 20 Jun 2005 11:10 On Fri, 17 Jun 2005 12:09:13 -0700, "Karl E. Peterson" <karl(a)mvps.org> wrote: Hi Karl, ý > ý > Dim objSystemInfo As Object ý > ý > Set objSystemInfo = CreateObject("ADSystemInfo") ý > ý > MsgBox "The current domain is: " & objSystemInfo.DomainShortName ý > ý > Set objSystemInfo = Nothing ý > ý ý > ý I don't know a lot about ADSI. Is that returning user or ý > workstation domain? ý > ý SystemInfo sounds very workstation-y, eh? ý > ý > If you need the domain for which the authenticated user is a member ý > you can pull it out of the user's distinguished name: ý > ý > MsgBox objSystemInfo.UserName ý ý How? I don't see my domain name there, at all. ý ý > If you need the domain name which the user is logged in to you can ý > use the RootDSE class: ý > ý > Dim objRootDSE As Object ý > ý > Set objRootDSE = GetObject("LDAP://RootDSE") ý > MsgBox objRootDSE.Get("DefaultNamingContext") ý ý That's kinda fuzzy, here. I'm logged into a domain known as "langroup", but I get ý "DC=clark,DC=root,DC=local" from that example (which corresponds to my primary DNS ý suffix of "clark.root.local"), same as your objSystemInfo.UserName suggestion. Yeah forgot to add a step. Both are returning the DNS name and not the actual domain name. If you want the "domain" name you need to fetch another directory object using the DNC value. The Name property of the directory object contains the relative name for the domain. Set objRootDSE = GetObject("LDAP://RootDSE") Set objDomainObject = GetObject("LDAP://" & objRootDSE.Get("defaultNamingContext")) MsgBox objDomainObject.Name Paul ~~~~ Microsoft MVP (Visual Basic)
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: Control cannot be loaded Next: Adobe Acrobat 7.0 Browser Control Issue |