Getting Doamin of the User presently Logged in.

S

Saradhi

Hi All,

Can any one tell me the way to check whether a given user name is a member
of domain users or not. I do not know the domain name as well. I should
retreive from the logged in user, in which user account my appliation is
running. If the system is not a part of domain controller then i should
check for the user name in the current stystem users list.

Can any one give me an example to solve my problem?
I need C# sample code for this one

-SARADHI
 
W

Willy Denoyette [MVP]

Saradhi said:
Hi All,

Can any one tell me the way to check whether a given user name is a member
of domain users or not. I do not know the domain name as well. I should
retreive from the logged in user, in which user account my appliation is
running. If the system is not a part of domain controller then i should
check for the user name in the current stystem users list.

Can any one give me an example to solve my problem?
I need C# sample code for this one

-SARADHI

If you need this from a user program running in the interactive logon
session (not a service), you can get the environment variables 'USERDOMAIN'
and 'COMPUTERNAME', if COMPUTERNAME == 'USERDOMAIN' the user is logged on
localy, if they are different, the user is logged on in domain USERDOMAIN.

Check:
Environment.UserDomainName
and
Environment.MachineName

in MSDN


Willy.
 
S

Saradhi

Actually, What I want is :
I need to find whether a particualr USERId is the members of a user domain?

For Ex, I have a domain called MyDomain and I logged in as Pardha.
Now I wanted to know whether Ravi is the part of my user domain.

Is there any way we can accomplish this in C#??

-SARADHI
 
U

U Saradhi

Actually, What I want is :
I need to find whether a particualr USERId is the members of a user
domain?

For Ex, I have a domain called MyDomain and I logged in as Pardha.
Now I wanted to know whether Ravi is the part of my user domain.

Is there any way we can accomplish this in C#??
-SARADHI
 
W

Willy Denoyette [MVP]

Saradhi said:
Actually, What I want is :
I need to find whether a particualr USERId is the members of a user
domain?

For Ex, I have a domain called MyDomain and I logged in as Pardha.
Now I wanted to know whether Ravi is the part of my user domain.

Is there any way we can accomplish this in C#??

-SARADHI

Yes it can be done ib C#, check the System.DirectoryServices namespace
classes, but before you do,
make sure you are a bit familiar with ADSI.

I suggest you to start reading this:
Active Directory Technology Backgrounder
and
Introduction to Active Directory Objects

another valuable resource is the platform SDK - System.DirectoryServices
topic (download :
http://www.microsoft.com/downloads/...43-e24f-4ea3-a93e-40c0ec4f68e5&DisplayLang=en)

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top