Environment.GetEnvironmentVariable("OS");可以获取操作系统名,我要获取电脑的域名,工作组名,要用什么呀,有人知道吗?

解决方案 »

  1.   

    开发的什么模式系统呢?b/s还是c/s的.??不同模式,方法不同,看帮助了.
      

  2.   

    http://www.3fwork.com/zs001/article/20100221215821a36636z.asp
      

  3.   

    原来的一个项目做好后,用户要求用域名登陆,这样的话就会出现两次登陆。 
    当用户访问页面时首先要域名登陆,然后再登陆本系统。 
    能不能在.net中取得用户域名登陆信息,这样就不用再进入本系统的登陆界面,而是一域名身份直接登陆到本系统?
    第1楼:
    MSDN
    第2楼:
    1.   在ASP.NET中专用属性: 
    获取服务器电脑名:Page.Server.ManchineName 
    获取用户信息:Page.User 
    获取客户端电脑名:Page.Request.UserHostName 
    获取客户端电脑IP:Page.Request.UserHostAddress 2.   在网络编程中的通用方法: 
    获取当前电脑名:static   System.Net.Dns.GetHostName() 
    根据电脑名取出全部IP地址:static   System.Net.Dns.Resolve(电脑名).AddressList 
    也可根据IP地址取出电脑名:static   System.Net.Dns.Resolve(IP地址).HostName 3.   系统环境类的通用属性: 
    当前电脑名:static   System.Environment.MachineName 
    当前电脑所属网域:static   System.Environment.UserDomainName 
    当前电脑用户:static   System.Environment.UserName
    第3楼:
    ls详尽
    第4楼:
    我现在只要在.net中得到用户在域登陆时的用户名就可以,其他的我也不需要。
    第5楼:
    模拟登陆 帮LZ顶
    第6楼:
    看看这两个方法 public       class       Win32API       
        {       
        [DllImport( "netapi32.dll ",EntryPoint= "NetApiBufferFree ")]       
        internal       static       extern       void       NetApiBufferFree(IntPtr       bufptr);       
            
        \\用来取得特定组所有用户的信息       
        [DllImport( "netapi32.dll ",EntryPoint= "NetLocalGroupGetMembers ")]       
        internal       static       extern       uint       NetLocalGroupGetMembers(       
        IntPtr       serverName,       
        IntPtr       GroupName,       
        uint       level,       
        ref       IntPtr       siptr,       
        uint       prefmaxLen,       
        ref       uint       entriesRead,       
        ref       uint       totalentries,       
        IntPtr       resumeHandle);       
            
        \\用来取得所有组的信息       
        [DllImport( "netapi32.dll ",EntryPoint= "NetLocalGroupEnum ")]       
        internal       static       extern       uint       NetLocalGroupEnum(       
        IntPtr       serverName,uint       level,ref       IntPtr       siptr,uint       prefmaxLen,ref       uint       entriesRead,ref       uint       totalLentries,IntPtr       resumeHandle);       
            
        [StructLayoutAttribute(LayoutKind.Sequential,CharSet=CharSet.Auto)]       
        internal       struct       LOCALGROUP_MEMBERS_INFO_1       
        {       
        public       IntPtr       lgrmitsid;       
        public       IntPtr       lgrmit_sidusage;       
        public       IntPtr       lgrmit_name;       
        }       
        [StructLayoutAttribute(LayoutKind.Sequential,CharSet=CharSet.Auto)]       
        internal       struct       LOCALGROUP_INFO_1       
        {       
        public       IntPtr       lpszGroupName;       
        public       IntPtr       lpszComment;       
        }       
        }       
        public       class       Form1       :       System.Windows.Forms.Form       
        {       
        private       System.Windows.Forms.TreeView       treeView1;       
        private       string[]       commentArray;       
        private       static       int       LOCALGROUP_MEMBERS_INFO_1_SIZE;       
        private       static       int       LOCALGROUP_INFO_1_SIZE;       
            
        private       System.ComponentModel.Container       components       =       null;       
            
        public       Form1()       
        {       
        InitializeComponent();       
        unsafe       
        {       
        LOCALGROUP_MEMBERS_INFO_1_SIZE=sizeof(Win32API.LOCALGROUP_MEMBERS_INFO_1);       
        LOCALGROUP_INFO_1_SIZE=sizeof(Win32API.LOCALGROUP_INFO_1);       
        }       
        }       
        [STAThread]       
        static       void       Main()           
        {       
        Application.Run(new       Form1());       
        }       
        private       void       Form1_Load(object       sender,       System.EventArgs       e)       
        {       
        uint       level=1,prefmaxLen=0xFFFFFFFF,entriesread=0,totalentries=0;       
        IntPtr       GroupInfoPtr,UserInfoPtr;       
        GroupInfoPtr=IntPtr.Zero;       
        UserInfoPtr=IntPtr.Zero;       
        Win32API.NetLocalGroupEnum(IntPtr.Zero,level,ref       GroupInfoPtr,prefmaxLen,ref       entriesread,ref       totalentries,IntPtr.Zero);       
        commentArray=new       string[totalentries];       
        for       (int       i=0;i <totalentries;i++)       
        {       
        int       newOffset=GroupInfoPtr.ToInt32()+LOCALGROUP_INFO_1_SIZE*i;       
        Win32API.LOCALGROUP_INFO_1       groupInfo=(Win32API.LOCALGROUP_INFO_1)Marshal.PtrToStructure(new       IntPtr(newOffset),typeof(Win32API.LOCALGROUP_INFO_1));       
        string       currentGroupName=Marshal.PtrToStringAuto(groupInfo.lpszGroupName);       
        \\用户描述       
        commentArray[i]=Marshal.PtrToStringAuto(groupInfo.lpszComment);       
        this.treeView1.Nodes.Add(currentGroupName);       
        uint       prefmaxLen_m=0xFFFFFFFF,entriesRead_m=0,totalEntries_m=0;       
        Win32API.NetLocalGroupGetMembers(IntPtr.Zero,groupInfo.lpszGroupName,1,ref       UserInfoPtr,prefmaxLen_m,ref       entriesRead_m,ref       totalEntries_m,IntPtr.Zero);       
        for       (int       j=0;j <totalEntries_m;j++)       
        {       
        int       newOffSet1=UserInfoPtr.ToInt32()+LOCALGROUP_MEMBERS_INFO_1_SIZE*j;       
        Win32API.LOCALGROUP_MEMBERS_INFO_1       memberInfo=(Win32API.LOCALGROUP_MEMBERS_INFO_1)Marshal.PtrToStructure(new       IntPtr(newOffSet1),typeof(Win32API.LOCALGROUP_MEMBERS_INFO_1));       
        string       currentUserName=Marshal.PtrToStringAuto(memberInfo.lgrmit_name);       
        this.treeView1.Nodes[i].Nodes.Add(currentUserName);       
        }       
        Win32API.NetApiBufferFree(UserInfoPtr);       
        }       
        Win32API.NetApiBufferFree(GroupInfoPtr);       
        }       
        }
    第7楼:
    用 
    string   s=System.Environment.UserDomainName; 
    就可以得到登陆用户名
      

  4.   

    http://www.3fwork.com/zs001/article/20100221215821a36636z.asp
      

  5.   

    单独取电脑信息,在C#中有提供的一个环境类!~也可以用系统的.dll去实现!~如用AD去做验证,微软也提供了方法.可以找找去!~