|
security
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
User IdentityIs there a way to get the current logged user on a computer from a windows
app. thanks, Victor Hello Victor,
WindowsIdentity id = WindowsIdentity.GetCurrent(); WindowsPrincipal p = new WindowsPrincipal(id); Console.WriteLine(p.Identity.Name); --------------------------------------- Dominick Baier - DevelopMentor http://www.leastprivilege.com Show quoteHide quote > Is there a way to get the current logged user on a computer from a > windows app. > > thanks, > > Victor > June 5, 2005
Hi Victor! You first need to import the System.Security.Principal namespace which contains the WindowsPrincipal & WindowsIdentity classes. Then you can just call: dim Name as string = WindowsIdentity.GetCurrent().Name ' Assumes the previously mentioned namespace was imported This makes it so that you just have one line of code for the username. This will return the name in the form of "[Computer|Domain]\UserName". Feel free to ask more questions! :-) Have a great day! -- Show quoteHide quoteJoseph Bittman Beta ID# 678424 Microsoft Certified Application Developer Web Site: http://71.35.110.42 Dynamic IP -- Check here for future changes "Dominick Baier [DevelopMentor]" <dbaier@pleasepleasenospamdevelop.com> wrote in message news:448453632535579177562875@news.microsoft.com... > Hello Victor, > > WindowsIdentity id = WindowsIdentity.GetCurrent(); > WindowsPrincipal p = new WindowsPrincipal(id); > > Console.WriteLine(p.Identity.Name); > > --------------------------------------- > Dominick Baier - DevelopMentor > http://www.leastprivilege.com > >> Is there a way to get the current logged user on a computer from a >> windows app. >> >> thanks, >> >> Victor >> > > > Great, it was very helpful.
Another question: With all this security objects and Active Directory access, can I call a webpage from a windows application that has Integrated security and respond to the authentication in the back gound with the current user info and display the page without the user having to do anything? thanks in advance, Victor Show quoteHide quote "Joseph Bittman MCAD" <RyanBitt***@msn.com> wrote in message news:ucAWeYeaFHA.3040@TK2MSFTNGP14.phx.gbl... > June 5, 2005 > > Hi Victor! You first need to import the System.Security.Principal > namespace which contains the WindowsPrincipal & WindowsIdentity classes. > Then you can just call: > > dim Name as string = WindowsIdentity.GetCurrent().Name ' Assumes the > previously mentioned namespace was imported > > This makes it so that you just have one line of code for the username. > This will return the name in the form of "[Computer|Domain]\UserName". > Feel free to ask more questions! :-) Have a great day! > > -- > Joseph Bittman Beta ID# 678424 > Microsoft Certified Application Developer > > Web Site: http://71.35.110.42 > Dynamic IP -- Check here for future changes > > "Dominick Baier [DevelopMentor]" <dbaier@pleasepleasenospamdevelop.com> > wrote in message news:448453632535579177562875@news.microsoft.com... >> Hello Victor, >> >> WindowsIdentity id = WindowsIdentity.GetCurrent(); >> WindowsPrincipal p = new WindowsPrincipal(id); >> >> Console.WriteLine(p.Identity.Name); >> >> --------------------------------------- >> Dominick Baier - DevelopMentor >> http://www.leastprivilege.com >> >>> Is there a way to get the current logged user on a computer from a >>> windows app. >>> >>> thanks, >>> >>> Victor >>> >> >> >> > > June 5, 2005
I assume you are using a web browser control? Well, if you are using the web browser control in Visual Studio 2003, and just do something like browser.navigate2(http://www.mydomain.com) and then your web site then has intergrated security.... There are two possiblities... 1) IE prompts you for the username & password 2) IE automatically takes the current username and password I believe there is an option in IE as to whether to automatically pass the current credentials, and if this is on then I don't think you will need to do any more coding than just navigating the browser to the site. Otherwise, I think that the only way is for the user to type in the credentials at the prompt or you would probably have to call unmanaged code to somehow supply the credentials... I would probably just quickly create a windows app project, add a web browser control, program a button to navigate the browser to the site and see what happens. If it prompts, then try looking under IE's Internet Option --> Advanced Tab, and then there is an option having to do with auto credentials. I hope this helps and please let me know what happens! :-) Thanks and have a great day! -- Show quoteHide quoteJoseph Bittman Beta ID# 678424 Microsoft Certified Application Developer Web Site: http://71.35.110.42 Dynamic IP -- Check here for future changes "Victor Rodriguez" <lasals***@hotmail.com> wrote in message news:eHm%23LPgaFHA.2496@TK2MSFTNGP14.phx.gbl... > Great, it was very helpful. > Another question: > With all this security objects and Active Directory access, can I call a > webpage from a windows application that has Integrated security and > respond to the authentication in the back gound with the current user info > and display the page without the user having to do anything? > > thanks in advance, > > Victor > > > > > "Joseph Bittman MCAD" <RyanBitt***@msn.com> wrote in message > news:ucAWeYeaFHA.3040@TK2MSFTNGP14.phx.gbl... >> June 5, 2005 >> >> Hi Victor! You first need to import the System.Security.Principal >> namespace which contains the WindowsPrincipal & WindowsIdentity classes. >> Then you can just call: >> >> dim Name as string = WindowsIdentity.GetCurrent().Name ' Assumes the >> previously mentioned namespace was imported >> >> This makes it so that you just have one line of code for the username. >> This will return the name in the form of "[Computer|Domain]\UserName". >> Feel free to ask more questions! :-) Have a great day! >> >> -- >> Joseph Bittman Beta ID# 678424 >> Microsoft Certified Application Developer >> >> Web Site: http://71.35.110.42 >> Dynamic IP -- Check here for future changes >> >> "Dominick Baier [DevelopMentor]" <dbaier@pleasepleasenospamdevelop.com> >> wrote in message news:448453632535579177562875@news.microsoft.com... >>> Hello Victor, >>> >>> WindowsIdentity id = WindowsIdentity.GetCurrent(); >>> WindowsPrincipal p = new WindowsPrincipal(id); >>> >>> Console.WriteLine(p.Identity.Name); >>> >>> --------------------------------------- >>> Dominick Baier - DevelopMentor >>> http://www.leastprivilege.com >>> >>>> Is there a way to get the current logged user on a computer from a >>>> windows app. >>>> >>>> thanks, >>>> >>>> Victor >>>> >>> >>> >>> >> >> > > Great, will do it like that...
Do you have any expirience creating VPN connection from .NET Code? thanks, Victor Show quoteHide quote "Joseph Bittman MCAD" <RyanBitt***@msn.com> wrote in message news:uJNzI0gaFHA.584@TK2MSFTNGP15.phx.gbl... > June 5, 2005 > > I assume you are using a web browser control? Well, if you are using > the web browser control in Visual Studio 2003, and just do something like > > browser.navigate2(http://www.mydomain.com) > > and then your web site then has intergrated security.... There are two > possiblities... > > 1) IE prompts you for the username & password > 2) IE automatically takes the current username and password > > I believe there is an option in IE as to whether to automatically pass the > current credentials, and if this is on then I don't think you will need to > do any more coding than just navigating the browser to the site. > Otherwise, I think that the only way is for the user to type in the > credentials at the prompt or you would probably have to call unmanaged > code to somehow supply the credentials... I would probably just quickly > create a windows app project, add a web browser control, program a button > to navigate the browser to the site and see what happens. If it prompts, > then try looking under IE's Internet Option --> Advanced Tab, and then > there is an option having to do with auto credentials. I hope this helps > and please let me know what happens! :-) Thanks and have a great day! > > -- > Joseph Bittman Beta ID# 678424 > Microsoft Certified Application Developer > > Web Site: http://71.35.110.42 > Dynamic IP -- Check here for future changes > > "Victor Rodriguez" <lasals***@hotmail.com> wrote in message > news:eHm%23LPgaFHA.2496@TK2MSFTNGP14.phx.gbl... >> Great, it was very helpful. >> Another question: >> With all this security objects and Active Directory access, can I call a >> webpage from a windows application that has Integrated security and >> respond to the authentication in the back gound with the current user >> info and display the page without the user having to do anything? >> >> thanks in advance, >> >> Victor >> >> >> >> >> "Joseph Bittman MCAD" <RyanBitt***@msn.com> wrote in message >> news:ucAWeYeaFHA.3040@TK2MSFTNGP14.phx.gbl... >>> June 5, 2005 >>> >>> Hi Victor! You first need to import the System.Security.Principal >>> namespace which contains the WindowsPrincipal & WindowsIdentity classes. >>> Then you can just call: >>> >>> dim Name as string = WindowsIdentity.GetCurrent().Name ' Assumes the >>> previously mentioned namespace was imported >>> >>> This makes it so that you just have one line of code for the username. >>> This will return the name in the form of "[Computer|Domain]\UserName". >>> Feel free to ask more questions! :-) Have a great day! >>> >>> -- >>> Joseph Bittman Beta ID# 678424 >>> Microsoft Certified Application Developer >>> >>> Web Site: http://71.35.110.42 >>> Dynamic IP -- Check here for future changes >>> >>> "Dominick Baier [DevelopMentor]" <dbaier@pleasepleasenospamdevelop.com> >>> wrote in message news:448453632535579177562875@news.microsoft.com... >>>> Hello Victor, >>>> >>>> WindowsIdentity id = WindowsIdentity.GetCurrent(); >>>> WindowsPrincipal p = new WindowsPrincipal(id); >>>> >>>> Console.WriteLine(p.Identity.Name); >>>> >>>> --------------------------------------- >>>> Dominick Baier - DevelopMentor >>>> http://www.leastprivilege.com >>>> >>>>> Is there a way to get the current logged user on a computer from a >>>>> windows app. >>>>> >>>>> thanks, >>>>> >>>>> Victor >>>>> >>>> >>>> >>>> >>> >>> >> >> > > June 5, 2005
Unfortunately I do not have experience with VPNs from .Net code. :-) Looking forward to the results of your test...... -- Show quoteHide quoteJoseph Bittman Beta ID# 678424 Microsoft Certified Application Developer Web Site: http://71.35.110.42 Dynamic IP -- Check here for future changes "Victor Rodriguez" <lasals***@hotmail.com> wrote in message news:%23VxrvZhaFHA.1040@TK2MSFTNGP10.phx.gbl... > Great, will do it like that... > > Do you have any expirience creating VPN connection from .NET Code? > > thanks, > > Victor > > > "Joseph Bittman MCAD" <RyanBitt***@msn.com> wrote in message > news:uJNzI0gaFHA.584@TK2MSFTNGP15.phx.gbl... >> June 5, 2005 >> >> I assume you are using a web browser control? Well, if you are using >> the web browser control in Visual Studio 2003, and just do something like >> >> browser.navigate2(http://www.mydomain.com) >> >> and then your web site then has intergrated security.... There are two >> possiblities... >> >> 1) IE prompts you for the username & password >> 2) IE automatically takes the current username and password >> >> I believe there is an option in IE as to whether to automatically pass >> the current credentials, and if this is on then I don't think you will >> need to do any more coding than just navigating the browser to the site. >> Otherwise, I think that the only way is for the user to type in the >> credentials at the prompt or you would probably have to call unmanaged >> code to somehow supply the credentials... I would probably just quickly >> create a windows app project, add a web browser control, program a button >> to navigate the browser to the site and see what happens. If it prompts, >> then try looking under IE's Internet Option --> Advanced Tab, and then >> there is an option having to do with auto credentials. I hope this helps >> and please let me know what happens! :-) Thanks and have a great day! >> >> -- >> Joseph Bittman Beta ID# 678424 >> Microsoft Certified Application Developer >> >> Web Site: http://71.35.110.42 >> Dynamic IP -- Check here for future changes >> >> "Victor Rodriguez" <lasals***@hotmail.com> wrote in message >> news:eHm%23LPgaFHA.2496@TK2MSFTNGP14.phx.gbl... >>> Great, it was very helpful. >>> Another question: >>> With all this security objects and Active Directory access, can I call a >>> webpage from a windows application that has Integrated security and >>> respond to the authentication in the back gound with the current user >>> info and display the page without the user having to do anything? >>> >>> thanks in advance, >>> >>> Victor >>> >>> >>> >>> >>> "Joseph Bittman MCAD" <RyanBitt***@msn.com> wrote in message >>> news:ucAWeYeaFHA.3040@TK2MSFTNGP14.phx.gbl... >>>> June 5, 2005 >>>> >>>> Hi Victor! You first need to import the System.Security.Principal >>>> namespace which contains the WindowsPrincipal & WindowsIdentity >>>> classes. Then you can just call: >>>> >>>> dim Name as string = WindowsIdentity.GetCurrent().Name ' Assumes the >>>> previously mentioned namespace was imported >>>> >>>> This makes it so that you just have one line of code for the username. >>>> This will return the name in the form of "[Computer|Domain]\UserName". >>>> Feel free to ask more questions! :-) Have a great day! >>>> >>>> -- >>>> Joseph Bittman Beta ID# 678424 >>>> Microsoft Certified Application Developer >>>> >>>> Web Site: http://71.35.110.42 >>>> Dynamic IP -- Check here for future changes >>>> >>>> "Dominick Baier [DevelopMentor]" <dbaier@pleasepleasenospamdevelop.com> >>>> wrote in message news:448453632535579177562875@news.microsoft.com... >>>>> Hello Victor, >>>>> >>>>> WindowsIdentity id = WindowsIdentity.GetCurrent(); >>>>> WindowsPrincipal p = new WindowsPrincipal(id); >>>>> >>>>> Console.WriteLine(p.Identity.Name); >>>>> >>>>> --------------------------------------- >>>>> Dominick Baier - DevelopMentor >>>>> http://www.leastprivilege.com >>>>> >>>>>> Is there a way to get the current logged user on a computer from a >>>>>> windows app. >>>>>> >>>>>> thanks, >>>>>> >>>>>> Victor >>>>>> >>>>> >>>>> >>>>> >>>> >>>> >>> >>> >> >> > > If your website uses Windows Authentication and impersonation is turned on,
then the website runs under the windows user account. You can enable impersonation as follows: <configuration> <system.web> <identity impersonate = "true "/> </system.web> </configuration> Show quoteHide quote "Joseph Bittman MCAD" wrote: > June 5, 2005 > > I assume you are using a web browser control? Well, if you are using the > web browser control in Visual Studio 2003, and just do something like > > browser.navigate2(http://www.mydomain.com) > > and then your web site then has intergrated security.... There are two > possiblities... > > 1) IE prompts you for the username & password > 2) IE automatically takes the current username and password > > I believe there is an option in IE as to whether to automatically pass the > current credentials, and if this is on then I don't think you will need to > do any more coding than just navigating the browser to the site. Otherwise, > I think that the only way is for the user to type in the credentials at the > prompt or you would probably have to call unmanaged code to somehow supply > the credentials... I would probably just quickly create a windows app > project, add a web browser control, program a button to navigate the browser > to the site and see what happens. If it prompts, then try looking under IE's > Internet Option --> Advanced Tab, and then there is an option having to do > with auto credentials. I hope this helps and please let me know what > happens! :-) Thanks and have a great day! > > -- > Joseph Bittman Beta ID# 678424 > Microsoft Certified Application Developer > > Web Site: http://71.35.110.42 > Dynamic IP -- Check here for future changes > > "Victor Rodriguez" <lasals***@hotmail.com> wrote in message > news:eHm%23LPgaFHA.2496@TK2MSFTNGP14.phx.gbl... > > Great, it was very helpful. > > Another question: > > With all this security objects and Active Directory access, can I call a > > webpage from a windows application that has Integrated security and > > respond to the authentication in the back gound with the current user info > > and display the page without the user having to do anything? > > > > thanks in advance, > > > > Victor > > > > > > > > > > "Joseph Bittman MCAD" <RyanBitt***@msn.com> wrote in message > > news:ucAWeYeaFHA.3040@TK2MSFTNGP14.phx.gbl... > >> June 5, 2005 > >> > >> Hi Victor! You first need to import the System.Security.Principal > >> namespace which contains the WindowsPrincipal & WindowsIdentity classes. > >> Then you can just call: > >> > >> dim Name as string = WindowsIdentity.GetCurrent().Name ' Assumes the > >> previously mentioned namespace was imported > >> > >> This makes it so that you just have one line of code for the username. > >> This will return the name in the form of "[Computer|Domain]\UserName". > >> Feel free to ask more questions! :-) Have a great day! > >> > >> -- > >> Joseph Bittman Beta ID# 678424 > >> Microsoft Certified Application Developer > >> > >> Web Site: http://71.35.110.42 > >> Dynamic IP -- Check here for future changes > >> > >> "Dominick Baier [DevelopMentor]" <dbaier@pleasepleasenospamdevelop.com> > >> wrote in message news:448453632535579177562875@news.microsoft.com... > >>> Hello Victor, > >>> > >>> WindowsIdentity id = WindowsIdentity.GetCurrent(); > >>> WindowsPrincipal p = new WindowsPrincipal(id); > >>> > >>> Console.WriteLine(p.Identity.Name); > >>> > >>> --------------------------------------- > >>> Dominick Baier - DevelopMentor > >>> http://www.leastprivilege.com > >>> > >>>> Is there a way to get the current logged user on a computer from a > >>>> windows app. > >>>> > >>>> thanks, > >>>> > >>>> Victor > >>>> > >>> > >>> > >>> > >> > >> > > > > > > >
Other interesting topics
|
|||||||||||||||||||||||